hello 404 Not Found
Al-HUWAITI Shell
Al-huwaiti


Server : Apache
System : Linux webm006.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User : chryzalihi ( 621211)
PHP Version : 8.3.31
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
Directory :  /home/c/h/r/chryzalihi/www/wp-content/languages/themes/the/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/c/h/r/chryzalihi/www/wp-content/languages/themes/the/admin.tar
assets/css/bloglo-meta-boxes.min.css000064400000003633152425717710013472 0ustar00#side-sortables .bloglo-meta-box-field {margin: 15px 0;}#side-sortables .bloglo-meta-box-field select {min-width: 100%;-webkit-box-sizing: border-box;box-sizing: border-box;}#side-sortables .bloglo-meta-box-field:last-child {margin-bottom: 0;}#side-sortables .bloglo-checkbox-row {margin-top: 0;--checkbox-input-size: 16px;line-height: 1.2;}#side-sortables .bloglo-checkbox-row .bloglo-checkbox-wrapper .bloglo-checked-icon {display: none;left: 50%;top: 50%;fill: #FFF;cursor: pointer;position: absolute;width: 16px;height: 16px;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;pointer-events: none;}#side-sortables .bloglo-checkbox-row input[type='checkbox'] {border: 1px solid #1e1e1e;border-radius: 2px;-webkit-appearance: none;-moz-appearance: none;appearance: none;}#side-sortables .bloglo-checkbox-row input[type='checkbox']:checked {background: #007cba;background: var(--wp-admin-theme-color);border-color: #007cba;border-color: var(--wp-admin-theme-color);}#side-sortables .bloglo-checkbox-row input[type='checkbox']:checked+.bloglo-checked-icon {display: none;}.block-editor-page #side-sortables .bloglo-meta-box-field input[type='checkbox']+.bloglo-checked-icon {display: block;}.block-editor-page #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row {min-height: 30px;}body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .components-base-control__label {display: block;font-weight: 600;}body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field input[type='checkbox'] {margin-right: 10px;}body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row {min-height: 26px;}body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row .components-base-control__field {-js-display: flex;display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-align: center;-ms-flex-align: center;align-items: center;}assets/css/bloglo-admin.min.css000064400000045525152425717710012524 0ustar00.hester-toggle{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box}.hester-toggle *,.hester-toggle :before,.hester-toggle :after{-webkit-box-sizing:inherit;box-sizing:inherit}.hester-toggle input[type="checkbox"]{display:none}.hester-toggle input[type="checkbox"]:checked + label .hester-toggle-switch{background-color:#0554f2!important}.hester-toggle input[type="checkbox"]:checked + label .hester-toggle-switch:after{-webkit-transform:translateX(11px);-ms-transform:translateX(11px);transform:translateX(11px)}.hester-toggle .hester-toggle-switch{background-color:#c7d5df;border-radius:8px;padding:2px;-webkit-transition:all .2s;transition:all .2s;outline:0;display:block;width:27px;height:16px;position:relative;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin:0 10px 0 0}.hester-toggle .hester-toggle-switch:after{position:relative;display:block;content:'';width:12px;height:12px;left:0;border-radius:50%;background:#fff;-webkit-transition:all .15s ease;transition:all .15s ease;-webkit-transform:translateX(0px);-ms-transform:translateX(0px);transform:translateX(0px)}.hester-toggle label{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:#232323}.hester-toggle label:hover .hester-toggle-switch{background-color:#86a4ba}.hester-toggle.large-toggle .hester-toggle-switch{border-radius:20px;width:36px;height:20px}.hester-toggle.large-toggle .hester-toggle-switch:after{width:16px;height:16px}.hester-toggle.large-toggle input[type="checkbox"]:checked + label .hester-toggle-switch:after{-webkit-transform:translateX(16px);-ms-transform:translateX(16px);transform:translateX(16px)}#wpcontent{padding:0;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px;line-height:1.8;color:#232323;min-height:calc(100vh - 190px)}#wpbody-content{padding:0 35px}#wpbody-content h2{-js-display:inline-flex;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-top:0;margin-bottom:0;font-size:18px;font-weight:400;color:#232323;line-height:1.2}#wpbody-content h2 svg{width:22px;height:22px;margin-left:7px}#wpcontent *,#wp-content *,#wp-content :before,#wp-content :after{-webkit-box-sizing:inherit;box-sizing:inherit}#wpbody{padding:0}#wpfooter{position:relative;padding:0 35px 10px}body{background-color:#f1f3f5;color:#232323}.spinner{display:none}.spinner.activated,.spinner.visible{display:inline-block;visibility:visible}.hester-container{width:100%;max-width:940px;margin:0 auto}.notice,.update-nag,div.error,div.updated{margin:5px auto!important;border-top:solid 1px #d6e1e8;border-right:solid 1px #d6e1e8;border-bottom:solid 1px #d6e1e8;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;max-width:940px;display:none}.notice.notice-info,.update-nag.notice-info,div.error.notice-info,div.updated.notice-info{border-left-color:#0554f2}.notice.notice-warning,.update-nag.notice-warning,div.error.notice-warning,div.updated.notice-warning{border-left-color:#f0b849}.notice.hester-notice,.update-nag.hester-notice,div.error.hester-notice,div.updated.hester-notice{display:block}.notice p a,.update-nag p a,div.error p a,div.updated p a{color:#0554f2}.notice p a:hover,.update-nag p a:hover,div.error p a:hover,div.updated p a:hover{color:#401EA1}.hester-info-icon{cursor:default}.hester-info-icon:hover svg{fill:#95b1c3}.hester-warning-icon svg{fill:#f0b849;-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.hester-buttons{margin-top:18px}.hester-btn,body.wp-core-ui .hester-btn{text-decoration:none;font-weight:500;border-radius:2px;font-size:13px;padding:3px 12px;border:1px solid rgba(0,0,0,0.15);-js-display:inline-flex;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-ms-flex-wrap:wrap;flex-wrap:wrap;line-height:1.8;height:auto;-webkit-box-shadow:none;box-shadow:none;text-shadow:none}.hester-btn.large-button,body.wp-core-ui .hester-btn.large-button{padding:8px 18px;font-size:14px}.hester-btn.primary,body.wp-core-ui .hester-btn.primary{background-color:#0554f2;color:#FFF;margin-right:5px}.hester-btn.secondary,body.wp-core-ui .hester-btn.secondary{color:#66717f;border-color:#c7d5df;background-color:rgba(0,0,0,0);font-weight:400}.hester-btn.secondary:hover,.hester-btn.secondary:focus,body.wp-core-ui .hester-btn.secondary:hover,body.wp-core-ui .hester-btn.secondary:focus{border-color:#728191;color:#232323;background-color:rgba(0,0,0,0)}.hester-btn:hover,.hester-btn:focus,body.wp-core-ui .hester-btn:hover,body.wp-core-ui .hester-btn:focus{background-color:#401EA1;-webkit-box-shadow:none!important;box-shadow:none!important;border-color:rgba(0,0,0,0.15)}.hester-btn:active,body.wp-core-ui .hester-btn:active{-webkit-transform:none;-ms-transform:none;transform:none}.hester-btn[disabled="disabled"],body.wp-core-ui .hester-btn[disabled="disabled"]{opacity:.25;pointer-events:none}.hester-btn svg,body.wp-core-ui .hester-btn svg{width:16px;height:16px;margin-right:7px}.hester-filters{margin-left:auto;padding-left:18px}.hester-dropdown-filter{text-decoration:none;color:#66717f;position:relative;padding:7px 0;-webkit-box-shadow:none;box-shadow:none;-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.hester-dropdown-filter:hover,.hester-dropdown-filter:focus{color:#232323;-webkit-box-shadow:none;box-shadow:none}.hester-dropdown-filter.open > ul{display:block}.hester-dropdown-filter > ul{display:none;margin:0;padding:10px 0;position:absolute;top:100%;right:-6px;background-color:#fff;border-radius:4px;width:180px;z-index:99;-webkit-box-shadow:0 0 40px rgba(51,59,72,0.2);box-shadow:0 0 40px rgba(51,59,72,0.2)}.hester-dropdown-filter > ul > li{display:block;padding:5px 25px;margin-bottom:5px;color:#66717f;line-height:1.4}.hester-dropdown-filter > ul > li:last-child{margin-bottom:0}.hester-dropdown-filter > ul > li:hover,.hester-dropdown-filter > ul > li:focus{color:#fff;background-color:#0554f2}.hester-dropdown-filter > ul > li.current{background-color:rgba(0,0,0,0.05);color:#232323}.hester-section-title{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.hester-modal{position:fixed;display:none;top:0;left:0;right:0;bottom:0;background-color:rgba(44,46,58,0.75);z-index:99999;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;overflow-y:scroll;opacity:0;-webkit-transition:all .2s ease-out .2s;transition:all .2s ease-out .2s}.hester-modal .hester-modal-container{opacity:0;-webkit-transition:all .2s ease-out 0;transition:all .2s ease-out 0;-webkit-transform:scale(1.2);-ms-transform:scale(1.2);transform:scale(1.2)}.hester-modal.hester-block{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex}.hester-modal.hester-visible{opacity:1;-webkit-transition-delay:0;transition-delay:0}.hester-modal.hester-visible .hester-modal-container{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);-webkit-transition-delay:.2s;transition-delay:.2s}.hester-info-icon,.hester-warning-icon{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-left:5px;position:relative}.hester-info-icon svg,.hester-warning-icon svg{fill:#b5c9d6}.hester-info-icon:hover svg,.hester-info-icon:focus svg,.hester-warning-icon:hover svg,.hester-warning-icon:focus svg{fill:#648da8}.hester-info-icon:hover .hester-tooltip,.hester-info-icon:focus .hester-tooltip,.hester-warning-icon:hover .hester-tooltip,.hester-warning-icon:focus .hester-tooltip{display:block}.hester-tooltip{display:none;position:absolute;background-color:#232323;color:#d6e1e8;font-size:13px;font-style:normal;width:300px;padding:16px 18px;z-index:991;border-radius:3px;line-height:1.6;bottom:100%;-webkit-transform:translate(0,-13px);-ms-transform:translate(0,-13px);transform:translate(0,-13px)}.hester-tooltip:after{content:'';width:10px;height:10px;background-color:#232323;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);position:absolute;top:calc(100% - 5px);left:var(--tooltip-left);margin-left:14px}.hester-tooltip.right-tooltip{left:100%;top:50%;-webkit-transform:translate(13px,-50%);-ms-transform:translate(13px,-50%);transform:translate(13px,-50%)}.hester-tooltip.top-right-tooltip{right:0;bottom:100%;-webkit-transform:translate(0,13px);-ms-transform:translate(0,13px);transform:translate(0,13px)}.hester-tooltip.top-right-tooltip:after{top:calc(100% - 6px);left:calc(100% - 25px);margin-left:0}.hester-tooltip.small-tooltip{top:5px;bottom:auto;left:50%;width:auto;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%);padding:6px 10px;font-size:11px;line-height:1.5;white-space:nowrap;font-weight:400}.hester-tooltip.small-tooltip:after{display:none}#hester-header{padding:12px 35px;background-color:#fff;position:relative;border-bottom:1px solid #d6e1e8;margin-bottom:9px}#hester-header > .hester-container{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}#hester-header .hester-logo img{height:35px;width:auto;display:block}#hester-header .hester-logo:focus{-webkit-box-shadow:none;box-shadow:none;outline:thin dotted #7f8a99;outline-offset:6px}#hester-header .hester-header-action{margin-left:auto;-js-display:inline-flex;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;font-size:13px}#hester-header .hester-header-action > a{padding:5px 13px;text-decoration:none;font-weight:500}#hester-header .hester-header-action > a:focus{-webkit-box-shadow:none;box-shadow:none}#hester-header .hester-header-action > a:first-child{border-radius:2px;background-color:#0554f2;color:#fff;border:1px solid rgba(0,0,0,0.15)}#hester-header .hester-header-action > a:first-child:hover,#hester-header .hester-header-action > a:first-child:focus{background-color:#401EA1}#hester-header .hester-header-action > a:first-child.secondary{background-color:rgba(0,0,0,0)}#hester-header .hester-header-action > a:last-child{margin-left:12px;border-radius:2px;border:1px solid #d6e1e8;color:#66717f}#hester-header .hester-header-action > a:last-child:hover,#hester-header .hester-header-action > a:last-child:focus{border-color:#728191;color:#232323;background-color:rgba(0,0,0,0)}.hester-tabs{position:relative;width:100%;padding:0;margin:9px 0 18px;background-color:#fff;border:1px solid #d6e1e8;border-radius:3px}.hester-tabs > ul{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;overflow:hidden;margin:0;padding:0 20px}.hester-tabs > ul > li{width:auto;-webkit-box-flex:0;-ms-flex:none;flex:none;border-bottom:2px solid transparent;border-top:2px solid transparent;text-align:center;margin:0 10px}.hester-tabs > ul > li:first-child{margin-left:0}.hester-tabs > ul > li:last-child{margin-right:0}.hester-tabs > ul > li:hover > a{color:#232323}.hester-tabs > ul > li.current-item{border-bottom-color:#0554f2}.hester-tabs > ul > li.current-item > a{color:#0554f2;font-weight:500}.hester-tabs > ul > li > a{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-decoration:none;width:auto;padding:10px 0;color:#66717f;font-weight:400}.hester-tabs > ul > li > a:focus{-webkit-box-shadow:none;box-shadow:none;outline:thin dotted #7f8a99}#wpbody-content .hester-section-title{margin:19px 0 8px}#wpbody-content h2.hester-section-title{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}#wpbody-content .hester-section{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;padding:15px 35px;margin-bottom:50px!important}#wpbody-content .hester-section.large-section{padding:40px 35px;-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;border-radius:3px;border:1px solid #d6e1e8;background-color:#fff;margin:38px 0}#wpbody-content .hester-section.large-section h2{padding-top:18px;text-align:center;line-height:1.4}#wpbody-content .hester-section.large-section p{max-width:480px;font-size:15px;line-height:1.7;text-align:center;color:#79879a}#wpbody-content .hester-section .hester-hero img{height:140px}#wpbody-content .hester-columns{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0;margin:-12px -12px 50px;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch}#wpbody-content .hester-columns .hester-column{width:33.33%;padding:12px}#wpbody-content .hester-columns .hester-column.column-6{width:50%}#wpbody-content .hester-columns .hester-column.column-12{width:100%}#wpbody-content .hester-columns .hester-changelog{max-height:500px;overflow:scroll}#wpbody-content .hester-columns.plugins .hester-box{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center}#wpbody-content .hester-columns.plugins .hester-box > div{-webkit-box-flex:1;-ms-flex:1;flex:1}#wpbody-content .hester-columns.plugins .plugin-image{position:absolute;top:5%;left:-10%;height:90%;opacity:.05;z-index:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#wpbody-content .hester-columns.plugins .plugin-image img{height:100%;pointer-events:none;border-radius:16px}#wpbody-content .hester-columns.plugins p{margin:5px 0 0}#wpbody-content .hester-columns.plugins .plugin-info{position:relative;z-index:2}#wpbody-content .hester-columns.plugins .hester-active-plugin{-js-display:inline-flex;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-right:auto;font-weight:400;color:#79ba49}#wpbody-content .hester-columns.plugins .hester-buttons{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding-top:0;margin-top:1.2em}#wpbody-content .hester-columns.plugins .dashicons{height:18px;margin-right:5px}#wpbody-content .hester-box{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;border-radius:3px;border:1px solid #d6e1e8;background-color:#fff;padding:20px 30px;height:100%;overflow:hidden;position:relative}#wpbody-content .hester-box p{color:#66717f;line-height:1.7}#wpbody-content .hester-box p:last-child{margin-bottom:0}#wpbody-content .hester-box h4{-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:15px;font-weight:600;margin:0;color:#232323}#wpbody-content .hester-box h4 i{width:auto;height:auto;color:#66717f;font-size:24px;line-height:16px;vertical-align:middle;opacity:.5;display:inline-block;padding-right:12px}#wpbody-content .hester-box .hester-buttons{margin:auto 0 0;padding-top:9px}#wpbody-content .changelog-version{font-size:11px;font-weight:500;line-height:1;text-align:center;white-space:nowrap;vertical-align:middle;border-radius:16px;color:#55718c;background-color:#d6e1ec;margin:0 12px;padding:5px 7px;margin-top:1px}#wpbody-content .hester-core-changelog{margin-top:-30px!important}#wpfooter{-webkit-backface-visibility:hidden;backface-visibility:hidden}#hester-footer{border-top:1px #d6e1e8 solid;border-bottom:1px #d6e1e8 solid;text-align:center;font-size:13px;color:#66717f;margin:0 -35px 18px}#hester-footer ul{margin:0 35px;padding:0;-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}#hester-footer ul li{margin:0}#hester-footer ul li a{text-decoration:none;-js-display:flex;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:15px 10px;color:inherit}#hester-footer ul li a:hover{color:#232323}#hester-footer ul li a:hover > span{text-decoration:underline}#hester-footer ul li a:focus{-webkit-box-shadow:none;box-shadow:none;outline:thin dotted #7f8a99}#hester-footer ul li a .dashicons{font-size:18px!important;height:18px;line-height:18px;margin-right:3px;text-decoration:none!important}#hester-footer ul li a .dashicons-heart{color:#e04b43}p#footer-upgrade{-webkit-backface-visibility:hidden;backface-visibility:hidden;float:none;text-align:center;font-size:11px;color:#8d98a7;text-transform:uppercase;letter-spacing:.1em;padding-bottom:1rem}p#footer-upgrade a{display:inline-block;text-decoration:none;padding:7px 5px;color:#66717f}p#footer-upgrade a:hover{color:#0554f2}p#footer-upgrade .dashicons{font-size:16px!important;height:16px;line-height:16px}@media screen and (max-width: 782px){.auto-fold #wpcontent{padding-left:0}#filter-container .theme,#wpbody-content .hester-columns .hester-column{width:50%}.plugin-image{display:none}}@media screen and (max-width: 600px){#wpbody-content .hester-section.large-section p{max-width:100%}.admin-bar #wpcontent{padding-top:46px}.hester-tabs > ul{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;padding:0}.hester-tabs > ul > li{padding-left:20px;padding-right:20px;margin:0;border-bottom:1px solid #d6e1e8!important}.hester-tabs > ul > li:last-child{border-bottom:none!important}#wpbody-content .hester-section-title{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;width:100%}#wpbody-content .hester-section-title .hester-filters{margin-left:0;padding-left:0}#wpbody-content .hester-section-title .hester-dropdown-filter > ul{right:auto;left:0}#wpbody-content .hester-section-title .hester-info-icon{display:none}#filter-container .theme,#wpbody-content .hester-columns .hester-column{width:100%!important}#wpbody{padding-top:0}#hester-header .hester-header-action > a:last-child{display:none}}assets/css/bloglo-meta-boxes.css000064400000004531152425717710012706 0ustar00/* ==========================================================================
*  Bloglo Meta Box Styles.
*  ========================================================================== */
#side-sortables .bloglo-meta-box-field {
    margin: 15px 0;
}

#side-sortables .bloglo-meta-box-field select {
    min-width: 100%;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

#side-sortables .bloglo-meta-box-field:last-child {
    margin-bottom: 0;
}

#side-sortables .bloglo-checkbox-row {
    margin-top: 0;
    --checkbox-input-size: 16px;
    line-height: 1.2;
}

#side-sortables .bloglo-checkbox-row .bloglo-checkbox-wrapper .bloglo-checked-icon {
    display: none;
    left: 50%;
    top: 50%;
    fill: #FFF;
    cursor: pointer;
    position: absolute;
    width: 16px;
    height: 16px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events: none;
}

#side-sortables .bloglo-checkbox-row input[type='checkbox'] {
    border: 1px solid #1e1e1e;
    border-radius: 2px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#side-sortables .bloglo-checkbox-row input[type='checkbox']:checked {
    background: #007cba;
    background: var(--wp-admin-theme-color);
    border-color: #007cba;
    border-color: var(--wp-admin-theme-color);
}

#side-sortables .bloglo-checkbox-row input[type='checkbox']:checked+.bloglo-checked-icon {
    display: none;
}

.block-editor-page #side-sortables .bloglo-meta-box-field input[type='checkbox']+.bloglo-checked-icon {
    display: block;
}

.block-editor-page #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row {
    min-height: 30px;
}

body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .components-base-control__label {
    display: block;
    font-weight: 600;
}

body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field input[type='checkbox'] {
    margin-right: 10px;
}

body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row {
    min-height: 26px;
}

body:not(.block-editor-page) #side-sortables .bloglo-meta-box-field .bloglo-checkbox-row .components-base-control__field {
    -js-display: flex;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}assets/css/select2.min.css000064400000035363152425717710011520 0ustar00.select2-container{max-width:100%;box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:#fff;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0!important;clip:rect(0 0 0 0)!important;-webkit-clip-path:inset(50%)!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:700}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--default .select2-selection--multiple{background-color:#fff;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:700;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid #000 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results > .select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:#fff}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top,white 50%,#eee 100%);background-image:-o-linear-gradient(top,white 50%,#eee 100%);background-image:linear-gradient(to bottom,white 50%,#eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF',endColorstr='#FFEEEEEE',GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:700;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top,#eee 50%,#ccc 100%);background-image:-o-linear-gradient(top,#eee 50%,#ccc 100%);background-image:linear-gradient(to bottom,#eee 50%,#ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE',endColorstr='#FFCCCCCC',GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent;border-style:solid;border-width:5px 4px 0;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888;border-width:0 4px 5px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top,white 0%,#eee 50%);background-image:-o-linear-gradient(top,white 0%,#eee 50%);background-image:linear-gradient(to bottom,white 0%,#eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF',endColorstr='#FFEEEEEE',GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top,#eee 50%,white 100%);background-image:-o-linear-gradient(top,#eee 50%,white 100%);background-image:linear-gradient(to bottom,#eee 50%,white 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE',endColorstr='#FFFFFFFF',GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:#fff;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:700;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results > .select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}assets/css/bloglo-block-editor-styles.css000064400000000000152425717710014524 0ustar00assets/css/select2.css000064400000042312152425717710010726 0ustar00.select2-container {
  max-width: 100%;
  box-sizing: border-box;
  display: inline-block;
  margin: 0;
  position: relative;
  vertical-align: middle; }
  .select2-container .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: 28px;
    user-select: none;
    -webkit-user-select: none; }
    .select2-container .select2-selection--single .select2-selection__rendered {
      display: block;
      padding-left: 8px;
      padding-right: 20px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap; }
    .select2-container .select2-selection--single .select2-selection__clear {
      position: relative; }
  .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
    padding-right: 8px;
    padding-left: 20px; }
  .select2-container .select2-selection--multiple {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    min-height: 32px;
    user-select: none;
    -webkit-user-select: none; }
    .select2-container .select2-selection--multiple .select2-selection__rendered {
      display: inline-block;
      overflow: hidden;
      padding-left: 8px;
      text-overflow: ellipsis;
      white-space: nowrap; }
  .select2-container .select2-search--inline {
    float: left; }
    .select2-container .select2-search--inline .select2-search__field {
      box-sizing: border-box;
      border: none;
      font-size: 100%;
      margin-top: 5px;
      padding: 0; }
      .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
        -webkit-appearance: none; }

.select2-dropdown {
  background-color: white;
  border: 1px solid #aaa;
  border-radius: 4px;
  box-sizing: border-box;
  display: block;
  position: absolute;
  left: -100000px;
  width: 100%;
  z-index: 1051; }

.select2-results {
  display: block; }

.select2-results__options {
  list-style: none;
  margin: 0;
  padding: 0; }

.select2-results__option {
  padding: 6px;
  user-select: none;
  -webkit-user-select: none; }
  .select2-results__option[aria-selected] {
    cursor: pointer; }

.select2-container--open .select2-dropdown {
  left: 0; }

.select2-container--open .select2-dropdown--above {
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0; }

.select2-container--open .select2-dropdown--below {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0; }

.select2-search--dropdown {
  display: block;
  padding: 4px; }
  .select2-search--dropdown .select2-search__field {
    padding: 4px;
    width: 100%;
    box-sizing: border-box; }
    .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
      -webkit-appearance: none; }
  .select2-search--dropdown.select2-search--hide {
    display: none; }

.select2-close-mask {
  border: 0;
  margin: 0;
  padding: 0;
  display: block;
  position: fixed;
  left: 0;
  top: 0;
  min-height: 100%;
  min-width: 100%;
  height: auto;
  width: auto;
  opacity: 0;
  z-index: 99;
  background-color: #fff;
  filter: alpha(opacity=0); }

.select2-hidden-accessible {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  -webkit-clip-path: inset(50%) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
  white-space: nowrap !important; }

.select2-container--default .select2-selection--single {
  background-color: #fff;
  border: 1px solid #aaa;
  border-radius: 4px; }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #444;
    line-height: 28px; }
  .select2-container--default .select2-selection--single .select2-selection__clear {
    cursor: pointer;
    float: right;
    font-weight: bold; }
  .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #999; }
  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 26px;
    position: absolute;
    top: 1px;
    right: 1px;
    width: 20px; }
    .select2-container--default .select2-selection--single .select2-selection__arrow b {
      border-color: #888 transparent transparent transparent;
      border-style: solid;
      border-width: 5px 4px 0 4px;
      height: 0;
      left: 50%;
      margin-left: -4px;
      margin-top: -2px;
      position: absolute;
      top: 50%;
      width: 0; }

.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
  float: left; }

.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
  left: 1px;
  right: auto; }

.select2-container--default.select2-container--disabled .select2-selection--single {
  background-color: #eee;
  cursor: default; }
  .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
    display: none; }

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent #888 transparent;
  border-width: 0 4px 5px 4px; }

.select2-container--default .select2-selection--multiple {
  background-color: white;
  border: 1px solid #aaa;
  border-radius: 4px;
  cursor: text; }
  .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    box-sizing: border-box;
    list-style: none;
    margin: 0;
    padding: 0 5px;
    width: 100%; }
    .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
      list-style: none; }
  .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
    color: #999;
    margin-top: 5px;
    float: left; }
  .select2-container--default .select2-selection--multiple .select2-selection__clear {
    cursor: pointer;
    float: right;
    font-weight: bold;
    margin-top: 5px;
    margin-right: 10px; }
  .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #e4e4e4;
    border: 1px solid #aaa;
    border-radius: 4px;
    cursor: default;
    float: left;
    margin-right: 5px;
    margin-top: 5px;
    padding: 0 5px; }
  .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: #999;
    cursor: pointer;
    display: inline-block;
    font-weight: bold;
    margin-right: 2px; }
    .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
      color: #333; }

.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
  float: right; }

.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
  margin-left: 5px;
  margin-right: auto; }

.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
  margin-left: 2px;
  margin-right: auto; }

.select2-container--default.select2-container--focus .select2-selection--multiple {
  border: solid black 1px;
  outline: 0; }

.select2-container--default.select2-container--disabled .select2-selection--multiple {
  background-color: #eee;
  cursor: default; }

.select2-container--default.select2-container--disabled .select2-selection__choice__remove {
  display: none; }

.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
  border-top-left-radius: 0;
  border-top-right-radius: 0; }

.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0; }

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid #aaa; }

.select2-container--default .select2-search--inline .select2-search__field {
  background: transparent;
  border: none;
  outline: 0;
  box-shadow: none;
  -webkit-appearance: textfield; }

.select2-container--default .select2-results > .select2-results__options {
  max-height: 200px;
  overflow-y: auto; }

.select2-container--default .select2-results__option[role=group] {
  padding: 0; }

.select2-container--default .select2-results__option[aria-disabled=true] {
  color: #999; }

.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: #ddd; }

.select2-container--default .select2-results__option .select2-results__option {
  padding-left: 1em; }
  .select2-container--default .select2-results__option .select2-results__option .select2-results__group {
    padding-left: 0; }
  .select2-container--default .select2-results__option .select2-results__option .select2-results__option {
    margin-left: -1em;
    padding-left: 2em; }
    .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
      margin-left: -2em;
      padding-left: 3em; }
      .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
        margin-left: -3em;
        padding-left: 4em; }
        .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
          margin-left: -4em;
          padding-left: 5em; }
          .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
            margin-left: -5em;
            padding-left: 6em; }

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: #5897fb;
  color: white; }

.select2-container--default .select2-results__group {
  cursor: default;
  display: block;
  padding: 6px; }

.select2-container--classic .select2-selection--single {
  background-color: #f7f7f7;
  border: 1px solid #aaa;
  border-radius: 4px;
  outline: 0;
  background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
  background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
  background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
  .select2-container--classic .select2-selection--single:focus {
    border: 1px solid #5897fb; }
  .select2-container--classic .select2-selection--single .select2-selection__rendered {
    color: #444;
    line-height: 28px; }
  .select2-container--classic .select2-selection--single .select2-selection__clear {
    cursor: pointer;
    float: right;
    font-weight: bold;
    margin-right: 10px; }
  .select2-container--classic .select2-selection--single .select2-selection__placeholder {
    color: #999; }
  .select2-container--classic .select2-selection--single .select2-selection__arrow {
    background-color: #ddd;
    border: none;
    border-left: 1px solid #aaa;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    height: 26px;
    position: absolute;
    top: 1px;
    right: 1px;
    width: 20px;
    background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
    background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
    background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
    background-repeat: repeat-x;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
    .select2-container--classic .select2-selection--single .select2-selection__arrow b {
      border-color: #888 transparent transparent transparent;
      border-style: solid;
      border-width: 5px 4px 0 4px;
      height: 0;
      left: 50%;
      margin-left: -4px;
      margin-top: -2px;
      position: absolute;
      top: 50%;
      width: 0; }

.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
  float: left; }

.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
  border: none;
  border-right: 1px solid #aaa;
  border-radius: 0;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  left: 1px;
  right: auto; }

.select2-container--classic.select2-container--open .select2-selection--single {
  border: 1px solid #5897fb; }
  .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
    background: transparent;
    border: none; }
    .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
      border-color: transparent transparent #888 transparent;
      border-width: 0 4px 5px 4px; }

.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
  background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
  background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }

.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
  background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
  background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }

.select2-container--classic .select2-selection--multiple {
  background-color: white;
  border: 1px solid #aaa;
  border-radius: 4px;
  cursor: text;
  outline: 0; }
  .select2-container--classic .select2-selection--multiple:focus {
    border: 1px solid #5897fb; }
  .select2-container--classic .select2-selection--multiple .select2-selection__rendered {
    list-style: none;
    margin: 0;
    padding: 0 5px; }
  .select2-container--classic .select2-selection--multiple .select2-selection__clear {
    display: none; }
  .select2-container--classic .select2-selection--multiple .select2-selection__choice {
    background-color: #e4e4e4;
    border: 1px solid #aaa;
    border-radius: 4px;
    cursor: default;
    float: left;
    margin-right: 5px;
    margin-top: 5px;
    padding: 0 5px; }
  .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
    color: #888;
    cursor: pointer;
    display: inline-block;
    font-weight: bold;
    margin-right: 2px; }
    .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
      color: #555; }

.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
  float: right;
  margin-left: 5px;
  margin-right: auto; }

.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
  margin-left: 2px;
  margin-right: auto; }

.select2-container--classic.select2-container--open .select2-selection--multiple {
  border: 1px solid #5897fb; }

.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
  border-top: none;
  border-top-left-radius: 0;
  border-top-right-radius: 0; }

.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0; }

.select2-container--classic .select2-search--dropdown .select2-search__field {
  border: 1px solid #aaa;
  outline: 0; }

.select2-container--classic .select2-search--inline .select2-search__field {
  outline: 0;
  box-shadow: none; }

.select2-container--classic .select2-dropdown {
  background-color: white;
  border: 1px solid transparent; }

.select2-container--classic .select2-dropdown--above {
  border-bottom: none; }

.select2-container--classic .select2-dropdown--below {
  border-top: none; }

.select2-container--classic .select2-results > .select2-results__options {
  max-height: 200px;
  overflow-y: auto; }

.select2-container--classic .select2-results__option[role=group] {
  padding: 0; }

.select2-container--classic .select2-results__option[aria-disabled=true] {
  color: grey; }

.select2-container--classic .select2-results__option--highlighted[aria-selected] {
  background-color: #3875d7;
  color: white; }

.select2-container--classic .select2-results__group {
  cursor: default;
  display: block;
  padding: 6px; }

.select2-container--classic.select2-container--open .select2-dropdown {
  border-color: #5897fb; }
assets/css/bloglo-admin.css000064400000057467152425717710011752 0ustar00/* ==========================================================================
*  Bloglo admin page related styles.
*  ========================================================================== */
/**
 * Import configuration file with variables.
 */
/**
 * Import base admin page styles.
 */
/*****************************************/
/* Admin page base styles
/*****************************************/
.hester-toggle {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

.hester-toggle *,
.hester-toggle *:before,
.hester-toggle *:after {
  -webkit-box-sizing: inherit;
  box-sizing: inherit;
}

.hester-toggle input[type="checkbox"] {
  display: none;
}

.hester-toggle input[type="checkbox"]:checked + label .hester-toggle-switch {
  background-color: #0554f2 !important;
}

.hester-toggle
  input[type="checkbox"]:checked
  + label
  .hester-toggle-switch:after {
  -webkit-transform: translateX(11px);
  -ms-transform: translateX(11px);
  transform: translateX(11px);
}

.hester-toggle .hester-toggle-switch {
  background-color: #c7d5df;
  border-radius: 8px;
  padding: 2px;
  -webkit-transition: all 0.2s;
  transition: all 0.2s;
  outline: 0;
  display: block;
  width: 27px;
  height: 16px;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  margin: 0 10px 0 0;
}

.hester-toggle .hester-toggle-switch:after {
  position: relative;
  display: block;
  content: "";
  width: 12px;
  height: 12px;
  left: 0;
  border-radius: 50%;
  background: #ffffff;
  -webkit-transition: all 0.15s ease;
  transition: all 0.15s ease;
  -webkit-transform: translateX(0px);
  -ms-transform: translateX(0px);
  transform: translateX(0px);
}

.hester-toggle label {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  color: #232323;
}

.hester-toggle label:hover .hester-toggle-switch {
  background-color: #86a4ba;
}

.hester-toggle.large-toggle .hester-toggle-switch {
  border-radius: 20px;
  width: 36px;
  height: 20px;
}

.hester-toggle.large-toggle .hester-toggle-switch:after {
  width: 16px;
  height: 16px;
}

.hester-toggle.large-toggle
  input[type="checkbox"]:checked
  + label
  .hester-toggle-switch:after {
  -webkit-transform: translateX(16px);
  -ms-transform: translateX(16px);
  transform: translateX(16px);
}

#wpcontent {
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.8;
  color: #232323;
  min-height: calc(100vh - 190px);
}

#wpbody-content {
  padding: 0 35px;
}

#wpbody-content h2 {
  -js-display: inline-flex;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  margin-top: 0;
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 400;
  color: #232323;
  line-height: 1.2;
}

#wpbody-content h2 svg {
  width: 22px;
  height: 22px;
  margin-left: 7px;
}

#wpcontent *,
#wp-content *,
#wp-content *:before,
#wp-content *:after {
  -webkit-box-sizing: inherit;
  box-sizing: inherit;
}

#wpbody {
  padding: 0;
}

#wpfooter {
  position: relative;
  padding: 0 35px 10px 35px;
}

body {
  background-color: #f1f3f5;
  color: #232323;
}

.spinner {
  display: none;
}

.spinner.activated,
.spinner.visible {
  display: inline-block;
  visibility: visible;
}

.hester-container {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}

.notice,
.update-nag,
div.error,
div.updated {
  margin: 5px auto !important;
  border-top: solid 1px #d6e1e8;
  border-right: solid 1px #d6e1e8;
  border-bottom: solid 1px #d6e1e8;
  border-radius: 3px;
  -webkit-box-shadow: none;
  box-shadow: none;
  max-width: 940px;
  display: none;
}

.notice.notice-info,
.update-nag.notice-info,
div.error.notice-info,
div.updated.notice-info {
  border-left-color: #0554f2;
}

.notice.notice-warning,
.update-nag.notice-warning,
div.error.notice-warning,
div.updated.notice-warning {
  border-left-color: #f0b849;
}

.notice.hester-notice,
.update-nag.hester-notice,
div.error.hester-notice,
div.updated.hester-notice {
  display: block;
}

.notice p a,
.update-nag p a,
div.error p a,
div.updated p a {
  color: #0554f2;
}

.notice p a:hover,
.update-nag p a:hover,
div.error p a:hover,
div.updated p a:hover {
  color: #401ea1;
}

.hester-info-icon {
  cursor: default;
}

.hester-info-icon:hover svg {
  fill: #95b1c3;
}

.hester-warning-icon svg {
  fill: #f0b849;
  -webkit-transform: rotate(180deg);
  -ms-transform: rotate(180deg);
  transform: rotate(180deg);
}

.hester-buttons {
  margin-top: 18px;
}

.hester-btn,
body.wp-core-ui .hester-btn {
  text-decoration: none;
  font-weight: 500;
  border-radius: 2px;
  font-size: 13px;
  padding: 3px 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  -js-display: inline-flex;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  line-height: 1.8;
  height: auto;
  -webkit-box-shadow: none;
  box-shadow: none;
  text-shadow: none;
}

.hester-btn.large-button,
body.wp-core-ui .hester-btn.large-button {
  padding: 8px 18px;
  font-size: 14px;
}

.hester-btn.primary,
body.wp-core-ui .hester-btn.primary {
  background-color: #0554f2;
  color: #fff;
  margin-right: 5px;
}

.hester-btn.secondary,
body.wp-core-ui .hester-btn.secondary {
  color: #66717f;
  border-color: #c7d5df;
  background-color: rgba(0, 0, 0, 0);
  font-weight: 400;
}

.hester-btn.secondary:hover,
.hester-btn.secondary:focus,
body.wp-core-ui .hester-btn.secondary:hover,
body.wp-core-ui .hester-btn.secondary:focus {
  border-color: #728191;
  color: #232323;
  background-color: rgba(0, 0, 0, 0);
}

.hester-btn:hover,
.hester-btn:focus,
body.wp-core-ui .hester-btn:hover,
body.wp-core-ui .hester-btn:focus {
  background-color: #401ea1;
  -webkit-box-shadow: none !important;
  box-shadow: none !important;
  border-color: rgba(0, 0, 0, 0.15);
}

.hester-btn:active,
body.wp-core-ui .hester-btn:active {
  -webkit-transform: none;
  -ms-transform: none;
  transform: none;
}

.hester-btn[disabled="disabled"],
body.wp-core-ui .hester-btn[disabled="disabled"] {
  opacity: 0.25;
  pointer-events: none;
}

.hester-btn svg,
body.wp-core-ui .hester-btn svg {
  width: 16px;
  height: 16px;
  margin-right: 7px;
}

.hester-filters {
  margin-left: auto;
  padding-left: 18px;
}

.hester-dropdown-filter {
  text-decoration: none;
  color: #66717f;
  position: relative;
  padding: 7px 0;
  -webkit-box-shadow: none;
  box-shadow: none;
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.hester-dropdown-filter:hover,
.hester-dropdown-filter:focus {
  color: #232323;
  -webkit-box-shadow: none;
  box-shadow: none;
}

.hester-dropdown-filter.open > ul {
  display: block;
}

.hester-dropdown-filter > ul {
  display: none;
  margin: 0;
  padding: 10px 0;
  position: absolute;
  top: 100%;
  right: -6px;
  background-color: #ffffff;
  border-radius: 4px;
  width: 180px;
  z-index: 99;
  -webkit-box-shadow: 0 0 40px rgba(51, 59, 72, 0.2);
  box-shadow: 0 0 40px rgba(51, 59, 72, 0.2);
}

.hester-dropdown-filter > ul > li {
  display: block;
  padding: 5px 25px;
  margin-bottom: 5px;
  color: #66717f;
  line-height: 1.4;
}

.hester-dropdown-filter > ul > li:last-child {
  margin-bottom: 0;
}

.hester-dropdown-filter > ul > li:hover,
.hester-dropdown-filter > ul > li:focus {
  color: #ffffff;
  background-color: #0554f2;
}

.hester-dropdown-filter > ul > li.current {
  background-color: rgba(0, 0, 0, 0.05);
  color: #232323;
}

.hester-section-title {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

.hester-modal {
  position: fixed;
  display: none;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(44, 46, 58, 0.75);
  z-index: 99999;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  overflow-y: scroll;
  opacity: 0;
  -webkit-transition: all 0.2s ease-out 0.2s;
  transition: all 0.2s ease-out 0.2s;
}

.hester-modal .hester-modal-container {
  opacity: 0;
  -webkit-transition: all 0.2s ease-out 0s;
  transition: all 0.2s ease-out 0s;
  -webkit-transform: scale(1.2);
  -ms-transform: scale(1.2);
  transform: scale(1.2);
}

.hester-modal.hester-block {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.hester-modal.hester-visible {
  opacity: 1;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}

.hester-modal.hester-visible .hester-modal-container {
  opacity: 1;
  -webkit-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
  -webkit-transition-delay: 0.2s;
  transition-delay: 0.2s;
}

/**
   * Import tooltips and info icon.
   */
/*****************************************/
/* Bloglo tooltip and info icon.
  /*****************************************/
.hester-info-icon,
.hester-warning-icon {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  margin-left: 5px;
  position: relative;
}

.hester-info-icon svg,
.hester-warning-icon svg {
  fill: #b5c9d6;
}

.hester-info-icon:hover svg,
.hester-info-icon:focus svg,
.hester-warning-icon:hover svg,
.hester-warning-icon:focus svg {
  fill: #648da8;
}

.hester-info-icon:hover .hester-tooltip,
.hester-info-icon:focus .hester-tooltip,
.hester-warning-icon:hover .hester-tooltip,
.hester-warning-icon:focus .hester-tooltip {
  display: block;
}

.hester-tooltip {
  display: none;
  position: absolute;
  background-color: #232323;
  color: #d6e1e8;
  font-size: 13px;
  font-style: normal;
  width: 300px;
  padding: 16px 18px;
  z-index: 991;
  border-radius: 3px;
  line-height: 1.6;
  bottom: 100%;
  -webkit-transform: translate(0, -13px);
  -ms-transform: translate(0, -13px);
  transform: translate(0, -13px);
}

.hester-tooltip:after {
  content: "";
  width: 10px;
  height: 10px;
  background-color: #232323;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
  position: absolute;
  top: calc(100% - 5px);
  left: var(--tooltip-left);
  margin-left: 14px;
}

.hester-tooltip.right-tooltip {
  left: 100%;
  top: 50%;
  -webkit-transform: translate(13px, -50%);
  -ms-transform: translate(13px, -50%);
  transform: translate(13px, -50%);
}

.hester-tooltip.top-right-tooltip {
  right: 0;
  bottom: 100%;
  -webkit-transform: translate(0, 13px);
  -ms-transform: translate(0, 13px);
  transform: translate(0, 13px);
}

.hester-tooltip.top-right-tooltip:after {
  top: calc(100% - 6px);
  left: calc(100% - 25px);
  margin-left: 0;
}

.hester-tooltip.small-tooltip {
  top: 5px;
  bottom: auto;
  left: 50%;
  width: auto;
  -webkit-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  transform: translateX(-50%);
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  font-weight: 400;
}

.hester-tooltip.small-tooltip:after {
  display: none;
}

/**
   * Import admin page header styles.
   */
/* ==========================================================================
  *  Bloglo admin page header styles.
  *  ========================================================================== */
#hester-header {
  padding: 12px 35px;
  background-color: #ffffff;
  position: relative;
  border-bottom: 1px solid #d6e1e8;
  margin-bottom: 9px;
}

#hester-header > .hester-container {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: start;
  -ms-flex-pack: start;
  justify-content: flex-start;
}

#hester-header .hester-logo img {
  height: 35px;
  width: auto;
  display: block;
}

#hester-header .hester-logo:focus {
  -webkit-box-shadow: none;
  box-shadow: none;
  outline: thin dotted #7f8a99;
  outline-offset: 6px;
}

#hester-header .hester-header-action {
  margin-left: auto;
  -js-display: inline-flex;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  font-size: 13px;
}

#hester-header .hester-header-action > a {
  padding: 5px 13px;
  text-decoration: none;
  font-weight: 500;
}

#hester-header .hester-header-action > a:focus {
  -webkit-box-shadow: none;
  box-shadow: none;
}

#hester-header .hester-header-action > a:first-child {
  border-radius: 2px;
  background-color: #0554f2;
  color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

#hester-header .hester-header-action > a:first-child:hover,
#hester-header .hester-header-action > a:first-child:focus {
  background-color: #401ea1;
}

#hester-header .hester-header-action > a:first-child.secondary {
  background-color: rgba(0, 0, 0, 0);
}

#hester-header .hester-header-action > a:last-child {
  margin-left: 12px;
  border-radius: 2px;
  border: 1px solid #d6e1e8;
  color: #66717f;
}

#hester-header .hester-header-action > a:last-child:hover,
#hester-header .hester-header-action > a:last-child:focus {
  border-color: #728191;
  color: #232323;
  background-color: rgba(0, 0, 0, 0);
}

/**
   * Import admin tabs styles.
   */
/* ==========================================================================
  *  Bloglo admin page tabs styles.
  *  ========================================================================== */
.hester-tabs {
  position: relative;
  width: 100%;
  padding: 0;
  margin: 9px 0 18px 0;
  background-color: #ffffff;
  border: 1px solid #d6e1e8;
  border-radius: 3px;
}

.hester-tabs > ul {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0 20px;
}

.hester-tabs > ul > li {
  width: auto;
  -webkit-box-flex: 0;
  -ms-flex: none;
  flex: none;
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  text-align: center;
  margin: 0 10px;
}

.hester-tabs > ul > li:first-child {
  margin-left: 0;
}

.hester-tabs > ul > li:last-child {
  margin-right: 0;
}

.hester-tabs > ul > li:hover > a {
  color: #232323;
}

.hester-tabs > ul > li.current-item {
  border-bottom-color: #0554f2;
}

.hester-tabs > ul > li.current-item > a {
  color: #0554f2;
  font-weight: 500;
}

.hester-tabs > ul > li > a {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  text-decoration: none;
  width: auto;
  padding: 10px 0;
  color: #66717f;
  font-weight: 400;
}

.hester-tabs > ul > li > a:focus {
  -webkit-box-shadow: none;
  box-shadow: none;
  outline: thin dotted #7f8a99;
}

/**
   * Import about page styles.
   */
#wpbody-content .hester-section-title {
  margin: 19px 0 8px;
}

#wpbody-content h2.hester-section-title {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

#wpbody-content .hester-section {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  padding: 15px 35px;
  margin-bottom: 50px !important;
}

#wpbody-content .hester-section.large-section {
  padding: 40px 35px;
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  border-radius: 3px;
  border: 1px solid #d6e1e8;
  background-color: #ffffff;
  margin: 38px 0;
}

#wpbody-content .hester-section.large-section h2 {
  padding-top: 18px;
  text-align: center;
  line-height: 1.4;
}

#wpbody-content .hester-section.large-section p {
  max-width: 480px;
  font-size: 15px;
  line-height: 1.7;
  text-align: center;
  color: #79879a;
}

#wpbody-content .hester-section .hester-hero img {
  height: 140px;
}

#wpbody-content .hester-columns {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  padding: 0;
  margin: -12px -12px 50px -12px;
  -webkit-box-align: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
}

#wpbody-content .hester-columns .hester-column {
  width: 33.33%;
  padding: 12px;
}

#wpbody-content .hester-columns .hester-column.column-6 {
  width: 50%;
}

#wpbody-content .hester-columns .hester-column.column-12 {
  width: 100%;
}

#wpbody-content .hester-columns .hester-changelog {
  max-height: 500px;
  overflow: scroll;
}

#wpbody-content .hester-columns.plugins .hester-box {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
}

#wpbody-content .hester-columns.plugins .hester-box > div {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

#wpbody-content .hester-columns.plugins .plugin-image {
  position: absolute;
  top: 5%;
  left: -10%;
  height: 90%;
  opacity: 0.05;
  z-index: 1;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

#wpbody-content .hester-columns.plugins .plugin-image img {
  height: 100%;
  pointer-events: none;
  border-radius: 16px;
}

#wpbody-content .hester-columns.plugins p {
  margin: 5px 0 0 0;
}

#wpbody-content .hester-columns.plugins .plugin-info {
  position: relative;
  z-index: 2;
}

#wpbody-content .hester-columns.plugins .hester-active-plugin {
  -js-display: inline-flex;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  margin-right: auto;
  font-weight: 400;
  color: #79ba49;
}

#wpbody-content .hester-columns.plugins .hester-buttons {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  padding-top: 0;
  margin-top: 1.2em;
}

#wpbody-content .hester-columns.plugins .dashicons {
  height: 18px;
  margin-right: 5px;
}

#wpbody-content .hester-box {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  border-radius: 3px;
  border: 1px solid #d6e1e8;
  background-color: #ffffff;
  padding: 20px 30px;
  height: 100%;
  overflow: hidden;
  position: relative;
}

#wpbody-content .hester-box p {
  color: #66717f;
  line-height: 1.7;
}

#wpbody-content .hester-box p:last-child {
  margin-bottom: 0;
}

#wpbody-content .hester-box h4 {
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: #232323;
}

#wpbody-content .hester-box h4 i {
  width: auto;
  height: auto;
  color: #66717f;
  font-size: 24px;
  line-height: 16px;
  vertical-align: middle;
  opacity: 0.5;
  display: inline-block;
  padding-right: 12px;
}

#wpbody-content .hester-box .hester-buttons {
  margin: auto 0 0 0;
  padding-top: 9px;
}

#wpbody-content .changelog-version {
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  border-radius: 16px;
  color: #55718c;
  background-color: #d6e1ec;
  margin: 0 12px;
  padding: 5px 7px;
  margin-top: 1px;
}

#wpbody-content .hester-core-changelog {
  margin-top: -30px !important;
}

/**
   * Import admin page footer styles.
   */
#wpfooter {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

#hester-footer {
  border-top: 1px #d6e1e8 solid;
  border-bottom: 1px #d6e1e8 solid;
  margin-top: 0;
  margin-bottom: 18px;
  margin-left: -35px;
  margin-right: -35px;
  text-align: center;
  font-size: 13px;
  color: #66717f;
}

#hester-footer ul {
  margin: 0 35px;
  padding: 0;
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

#hester-footer ul li {
  margin: 0;
}

#hester-footer ul li a {
  text-decoration: none;
  -js-display: flex;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  padding: 15px 10px;
  color: inherit;
}

#hester-footer ul li a:hover {
  color: #232323;
}

#hester-footer ul li a:hover > span {
  text-decoration: underline;
}

#hester-footer ul li a:focus {
  -webkit-box-shadow: none;
  box-shadow: none;
  outline: thin dotted #7f8a99;
}

#hester-footer ul li a .dashicons {
  font-size: 18px !important;
  height: 18px;
  line-height: 18px;
  margin-right: 3px;
  text-decoration: none !important;
}

#hester-footer ul li a .dashicons-heart {
  color: #e04b43;
}

p#footer-upgrade {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  float: none;
  text-align: center;
  font-size: 11px;
  color: #8d98a7;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 1rem;
}

p#footer-upgrade a {
  display: inline-block;
  text-decoration: none;
  padding: 7px 5px;
  color: #66717f;
}

p#footer-upgrade a:hover {
  color: #0554f2;
}

p#footer-upgrade .dashicons {
  font-size: 16px !important;
  height: 16px;
  line-height: 16px;
}

/**
   * Import admin page responsive styles.
   */
/*****************************************/
/* Admin page responsive styles
  /*****************************************/
@media screen and (max-width: 782px) {
  .auto-fold #wpcontent {
    padding-left: 0;
  }
  #filter-container .theme,
  #wpbody-content .hester-columns .hester-column {
    width: 50%;
  }
  .plugin-image {
    display: none;
  }
}
@media screen and (max-width: 600px) {
  #wpbody-content .hester-section.large-section p {
    max-width: 100%;
  }
  .admin-bar #wpcontent {
    padding-top: 46px;
  }
  .hester-tabs > ul {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    padding: 0;
  }
  .hester-tabs > ul > li {
    padding-left: 20px;
    padding-right: 20px;
    margin: 0;
    border-bottom: 1px solid #d6e1e8 !important;
  }
  .hester-tabs > ul > li:last-child {
    border-bottom: none !important;
  }
  #wpbody-content .hester-section-title {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    width: 100%;
  }
  #wpbody-content .hester-section-title .hester-filters {
    margin-left: 0;
    padding-left: 0;
  }
  #wpbody-content .hester-section-title .hester-dropdown-filter > ul {
    right: auto;
    left: 0;
  }
  #wpbody-content .hester-section-title .hester-info-icon {
    display: none;
  }
  #filter-container .theme,
  #wpbody-content .hester-columns .hester-column {
    width: 100% !important;
  }
  #wpbody {
    padding-top: 0;
  }
  #hester-header .hester-header-action > a:last-child {
    display: none;
  }
}
assets/css/bloglo-block-editor-styles.min.css000064400000000000152425717710015306 0ustar00assets/js/dev/bloglo-admin.js000064400000011507152425717710012161 0ustar00//--------------------------------------------------------------------//
// Bloglo script that handles our admin functionality.
//--------------------------------------------------------------------//

(function ($) {
  "use strict";

  /**
   * Holds most important methods that bootstrap the whole admin area.
   *
   * @type {Object}
   */
  var BlogloAdmin = {
    /**
     * Start the engine.
     *
     * @since 1.0.0
     */
    init: function () {
      // Document ready
      $(document).ready(BlogloAdmin.ready);

      // Window load
      $(window).on("load", BlogloAdmin.load);

      // Bind UI actions
      BlogloAdmin.bindUIActions();

      // Trigger event when Bloglo fully loaded
      $(document).trigger("blogloReady");
    },

    //--------------------------------------------------------------------//
    // Events
    //--------------------------------------------------------------------//

    /**
     * Document ready.
     *
     * @since 1.0.0
     */
    ready: function () {},

    /**
     * Window load.
     *
     * @since 1.0.0
     */
    load: function () {
      // Trigger resize once everything loaded.
      window.dispatchEvent(new Event("resize"));
    },

    /**
     * Window resize.
     *
     * @since 1.0.0
     */
    resize: function () {},

    //--------------------------------------------------------------------//
    // Functions
    //--------------------------------------------------------------------//

    /**
     * Bind UI actions.
     *
     * @since 1.0.0
     */
    bindUIActions: function () {
      var $wrap = $("#wpwrap");
      var $body = $("body");
      var $this;

      $wrap.on("click", ".plugins .hester-btn:not(.active)", function (e) {
        e.preventDefault();

        if ($wrap.find(".plugins .hester-btn.in-progress").length) {
          return;
        }

        $this = $(this);

        BlogloAdmin.pluginAction($this);
      });

      $(document).on(
        "wp-plugin-install-success",
        BlogloAdmin.pluginInstallSuccess
      );
      $(document).on("wp-plugin-install-error", BlogloAdmin.pluginInstallError);
    },

    pluginAction: function ($button) {
      $button
        .addClass("in-progress")
        .attr("disabled", "disabled")
        .html(hester_strings.texts[$button.data("action") + "-inprogress"]);

      if ("install" === $button.data("action")) {
        if (
          wp.updates.shouldRequestFilesystemCredentials &&
          !wp.updates.ajaxLocked
        ) {
          wp.updates.requestFilesystemCredentials(event);

          $(document).on("credential-modal-cancel", function () {
            $button
              .removeAttr("disabled")
              .removeClass("in-progress")
              .html(hester_strings.texts.install);

            wp.a11y.speak(wp.updates.l10n.updateCancel, "polite");
          });
        }

        wp.updates.installPlugin({
          slug: $button.data("plugin"),
        });
      } else {
        var data = {
          _ajax_nonce: hester_strings.wpnonce, // eslint-disable-line camelcase
          plugin: $button.data("plugin"),
          action: "hester-plugin-" + $button.data("action"),
        };

        $.post(hester_strings.ajaxurl, data, function (response) {
          if (response.success) {
            if ($button.data("redirect")) {
              window.location.href = $button.data("redirect");
            } else {
              location.reload();
            }
          } else {
            $(".plugins .hester-btn.in-progress")
              .removeAttr("disabled")
              .removeClass("in-progress primary")
              .addClass("secondary")
              .html(hester_strings.texts.retry);
          }
        });
      }
    },

    pluginInstallSuccess: function (event, response) {
      event.preventDefault();

      var $message = jQuery(event.target);
      var $init = $message.data("init");
      var activatedSlug;

      if ("undefined" === typeof $init) {
        activatedSlug = response.slug;
      } else {
        activatedSlug = $init;
      }

      var $button = $('.plugins a[data-plugin="' + activatedSlug + '"]');

      $button.data("action", "activate");

      BlogloAdmin.pluginAction($button);
    },

    pluginInstallError: function (event, response) {
      event.preventDefault();

      var $message = jQuery(event.target);
      var $init = $message.data("init");
      var activatedSlug;

      if ("undefined" === typeof $init) {
        activatedSlug = response.slug;
      } else {
        activatedSlug = $init;
      }

      var $button = $('.plugins a[data-plugin="' + activatedSlug + '"]');

      $button
        .attr("disabled", "disabled")
        .removeClass("in-progress primary")
        .addClass("secondary")
        .html(wp.updates.l10n.installFailedShort);
    },
  }; // END var BlogloAdmin

  BlogloAdmin.init();
  window.blogloadmin = BlogloAdmin;
})(jQuery);
assets/js/bloglo-admin.min.js000064400000004013152425717710012157 0ustar00!function(t){"use strict";var e={init:function(){t(document).ready(e.ready),t(window).on("load",e.load),e.bindUIActions(),t(document).trigger("blogloReady")},ready:function(){},load:function(){window.dispatchEvent(new Event("resize"))},resize:function(){},bindUIActions:function(){var n,a=t("#wpwrap");t("body"),a.on("click",".plugins .hester-btn:not(.active)",function(s){s.preventDefault(),a.find(".plugins .hester-btn.in-progress").length||(n=t(this),e.pluginAction(n))}),t(document).on("wp-plugin-install-success",e.pluginInstallSuccess),t(document).on("wp-plugin-install-error",e.pluginInstallError)},pluginAction:function(e){if(e.addClass("in-progress").attr("disabled","disabled").html(hester_strings.texts[e.data("action")+"-inprogress"]),"install"===e.data("action"))wp.updates.shouldRequestFilesystemCredentials&&!wp.updates.ajaxLocked&&(wp.updates.requestFilesystemCredentials(event),t(document).on("credential-modal-cancel",function(){e.removeAttr("disabled").removeClass("in-progress").html(hester_strings.texts.install),wp.a11y.speak(wp.updates.l10n.updateCancel,"polite")})),wp.updates.installPlugin({slug:e.data("plugin")});else{var n={_ajax_nonce:hester_strings.wpnonce,plugin:e.data("plugin"),action:"hester-plugin-"+e.data("action")};t.post(hester_strings.ajaxurl,n,function(n){n.success?e.data("redirect")?window.location.href=e.data("redirect"):location.reload():t(".plugins .hester-btn.in-progress").removeAttr("disabled").removeClass("in-progress primary").addClass("secondary").html(hester_strings.texts.retry)})}},pluginInstallSuccess:function(n,a){n.preventDefault();var s,i=jQuery(n.target).data("init");s=void 0===i?a.slug:i;var l=t('.plugins a[data-plugin="'+s+'"]');l.data("action","activate"),e.pluginAction(l)},pluginInstallError:function(e,n){e.preventDefault();var a,s=jQuery(e.target).data("init");a=void 0===s?n.slug:s,t('.plugins a[data-plugin="'+a+'"]').attr("disabled","disabled").removeClass("in-progress primary").addClass("secondary").html(wp.updates.l10n.installFailedShort)}};e.init(),window.blogloadmin=e}(jQuery);assets/js/libs/select2.min.js000064400000224760152425717710012122 0ustar00/*! Select2 4.0.6-rc.1 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=function(b,c){return void 0===c&&(c="undefined"!=typeof window?require("jquery"):require("jquery")(b)),a(c),c}:a(jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return v.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o=b&&b.split("/"),p=t.map,q=p&&p["*"]||{};if(a){for(a=a.split("/"),g=a.length-1,t.nodeIdCompat&&x.test(a[g])&&(a[g]=a[g].replace(x,"")),"."===a[0].charAt(0)&&o&&(n=o.slice(0,o.length-1),a=n.concat(a)),k=0;k<a.length;k++)if("."===(m=a[k]))a.splice(k,1),k-=1;else if(".."===m){if(0===k||1===k&&".."===a[2]||".."===a[k-1])continue;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}if((o||q)&&p){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),o)for(l=o.length;l>0;l-=1)if((e=p[o.slice(0,l).join("/")])&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&q&&q[d]&&(i=q[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=w.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),o.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){r[a]=b}}function j(a){if(e(s,a)){var c=s[a];delete s[a],u[a]=!0,n.apply(b,c)}if(!e(r,a)&&!e(u,a))throw new Error("No "+a);return r[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return a?k(a):[]}function m(a){return function(){return t&&t.config&&t.config[a]||{}}}var n,o,p,q,r={},s={},t={},u={},v=Object.prototype.hasOwnProperty,w=[].slice,x=/\.js$/;p=function(a,b){var c,d=k(a),e=d[0],g=b[1];return a=d[1],e&&(e=f(e,g),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(g)):f(a,g):(a=f(a,g),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},q={require:function(a){return g(a)},exports:function(a){var b=r[a];return void 0!==b?b:r[a]={}},module:function(a){return{id:a,uri:"",exports:r[a],config:m(a)}}},n=function(a,c,d,f){var h,k,m,n,o,t,v,w=[],x=typeof d;if(f=f||a,t=l(f),"undefined"===x||"function"===x){for(c=!c.length&&d.length?["require","exports","module"]:c,o=0;o<c.length;o+=1)if(n=p(c[o],t),"require"===(k=n.f))w[o]=q.require(a);else if("exports"===k)w[o]=q.exports(a),v=!0;else if("module"===k)h=w[o]=q.module(a);else if(e(r,k)||e(s,k)||e(u,k))w[o]=j(k);else{if(!n.p)throw new Error(a+" missing "+k);n.p.load(n.n,g(f,!0),i(k),{}),w[o]=r[k]}m=d?d.apply(r[a],w):void 0,a&&(h&&h.exports!==b&&h.exports!==r[a]?r[a]=h.exports:m===b&&v||(r[a]=m))}else a&&(r[a]=d)},a=c=o=function(a,c,d,e,f){if("string"==typeof a)return q[a]?q[a](c):j(p(a,l(c)).f);if(!a.splice){if(t=a,t.deps&&o(t.deps,t.callback),!c)return;c.splice?(a=c,c=d,d=null):a=b}return c=c||function(){},"function"==typeof d&&(d=e,e=f),e?n(b,a,c,d):setTimeout(function(){n(b,a,c,d)},4),o},o.config=function(a){return o(a)},a._defined=r,d=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(r,a)||e(s,a)||(s[a]=[a,b,c])},d.amd={jQuery:!0}}(),b.requirejs=a,b.require=c,b.define=d}}(),b.define("almond",function(){}),b.define("jquery",[],function(){var b=a||$;return null==b&&console&&console.error&&console.error("Select2: An instance of jQuery or a jQuery-compatible library was not found. Make sure that you are including jQuery before Select2 on your web page."),b}),b.define("select2/utils",["jquery"],function(a){function b(a){var b=a.prototype,c=[];for(var d in b){"function"==typeof b[d]&&("constructor"!==d&&c.push(d))}return c}var c={};c.Extend=function(a,b){function c(){this.constructor=a}var d={}.hasOwnProperty;for(var e in b)d.call(b,e)&&(a[e]=b[e]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},c.Decorate=function(a,c){function d(){var b=Array.prototype.unshift,d=c.prototype.constructor.length,e=a.prototype.constructor;d>0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;h<g.length;h++){var i=g[h];d.prototype[i]=a.prototype[i]}for(var j=(function(a){var b=function(){};a in d.prototype&&(b=d.prototype[a]);var e=c.prototype[a];return function(){return Array.prototype.unshift.call(arguments,b),e.apply(this,arguments)}}),k=0;k<f.length;k++){var l=f[k];d.prototype[l]=j(l)}return d};var d=function(){this.listeners={}};d.prototype.on=function(a,b){this.listeners=this.listeners||{},a in this.listeners?this.listeners[a].push(b):this.listeners[a]=[b]},d.prototype.trigger=function(a){var b=Array.prototype.slice,c=b.call(arguments,1);this.listeners=this.listeners||{},null==c&&(c=[]),0===c.length&&c.push({}),c[0]._type=a,a in this.listeners&&this.invoke(this.listeners[a],b.call(arguments,1)),"*"in this.listeners&&this.invoke(this.listeners["*"],arguments)},d.prototype.invoke=function(a,b){for(var c=0,d=a.length;c<d;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;c<a;c++){b+=Math.floor(36*Math.random()).toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e<c.length;e++){var f=c[e];f=f.substring(0,1).toLowerCase()+f.substring(1),f in d||(d[f]={}),e==c.length-1&&(d[f]=a[b]),d=d[f]}delete a[b]}}return a},c.hasScroll=function(b,c){var d=a(c),e=c.style.overflowX,f=c.style.overflowY;return(e!==f||"hidden"!==f&&"visible"!==f)&&("scroll"===e||"scroll"===f||(d.innerHeight()<c.scrollHeight||d.innerWidth()<c.scrollWidth))},c.escapeMarkup=function(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c.__cache={};var e=0;return c.GetUniqueElementId=function(a){var b=a.getAttribute("data-select2-id");return null==b&&(a.id?(b=a.id,a.setAttribute("data-select2-id",b)):(a.setAttribute("data-select2-id",++e),b=e.toString())),b},c.StoreData=function(a,b,d){var e=c.GetUniqueElementId(a);c.__cache[e]||(c.__cache[e]={}),c.__cache[e][b]=d},c.GetData=function(b,d){var e=c.GetUniqueElementId(b);return d?c.__cache[e]&&null!=c.__cache[e][d]?c.__cache[e][d]:a(b).data(d):c.__cache[e]},c.RemoveData=function(a){var b=c.GetUniqueElementId(a);null!=c.__cache[b]&&delete c.__cache[b]},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<ul class="select2-results__options" role="tree"></ul>');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('<li role="treeitem" aria-live="assertive" class="select2-results__option"></li>'),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c<a.results.length;c++){var d=a.results[c],e=this.option(d);b.push(e)}this.$results.append(b)},c.prototype.position=function(a,b){b.find(".select2-results").append(a)},c.prototype.sort=function(a){return this.options.get("sorter")(a)},c.prototype.highlightFirstItem=function(){var a=this.$results.find(".select2-results__option[aria-selected]"),b=a.filter("[aria-selected=true]");b.length>0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var c=this;this.data.current(function(d){var e=a.map(d,function(a){return a.id.toString()});c.$results.find(".select2-results__option[aria-selected]").each(function(){var c=a(this),d=b.GetData(this,"data"),f=""+d.id;null!=d.element&&d.element.selected||null==d.element&&a.inArray(f,e)>-1?c.attr("aria-selected","true"):c.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(c){var d=document.createElement("li");d.className="select2-results__option";var e={role:"treeitem","aria-selected":"false"};c.disabled&&(delete e["aria-selected"],e["aria-disabled"]="true"),null==c.id&&delete e["aria-selected"],null!=c._resultId&&(d.id=c._resultId),c.title&&(d.title=c.title),c.children&&(e.role="group",e["aria-label"]=c.text,delete e["aria-selected"]);for(var f in e){var g=e[f];d.setAttribute(f,g)}if(c.children){var h=a(d),i=document.createElement("strong");i.className="select2-results__group";a(i);this.template(c,i);for(var j=[],k=0;k<c.children.length;k++){var l=c.children[k],m=this.option(l);j.push(m)}var n=a("<ul></ul>",{class:"select2-results__options select2-results__options--nested"});n.append(j),h.append(i),h.append(n)}else this.template(c,d);return b.StoreData(d,"data",c),d},c.prototype.bind=function(c,d){var e=this,f=c.id+"-results";this.$results.attr("id",f),c.on("results:all",function(a){e.clear(),e.append(a.data),c.isOpen()&&(e.setClasses(),e.highlightFirstItem())}),c.on("results:append",function(a){e.append(a.data),c.isOpen()&&e.setClasses()}),c.on("query",function(a){e.hideMessages(),e.showLoading(a)}),c.on("select",function(){c.isOpen()&&(e.setClasses(),e.highlightFirstItem())}),c.on("unselect",function(){c.isOpen()&&(e.setClasses(),e.highlightFirstItem())}),c.on("open",function(){e.$results.attr("aria-expanded","true"),e.$results.attr("aria-hidden","false"),e.setClasses(),e.ensureHighlightVisible()}),c.on("close",function(){e.$results.attr("aria-expanded","false"),e.$results.attr("aria-hidden","true"),e.$results.removeAttr("aria-activedescendant")}),c.on("results:toggle",function(){var a=e.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),c.on("results:select",function(){var a=e.getHighlightedResults();if(0!==a.length){var c=b.GetData(a[0],"data");"true"==a.attr("aria-selected")?e.trigger("close",{}):e.trigger("select",{data:c})}}),c.on("results:previous",function(){var a=e.getHighlightedResults(),b=e.$results.find("[aria-selected]"),c=b.index(a);if(!(c<=0)){var d=c-1;0===a.length&&(d=0);var f=b.eq(d);f.trigger("mouseenter");var g=e.$results.offset().top,h=f.offset().top,i=e.$results.scrollTop()+(h-g);0===d?e.$results.scrollTop(0):h-g<0&&e.$results.scrollTop(i)}}),c.on("results:next",function(){var a=e.getHighlightedResults(),b=e.$results.find("[aria-selected]"),c=b.index(a),d=c+1;if(!(d>=b.length)){var f=b.eq(d);f.trigger("mouseenter");var g=e.$results.offset().top+e.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=e.$results.scrollTop()+h-g;0===d?e.$results.scrollTop(0):h>g&&e.$results.scrollTop(i)}}),c.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),c.on("results:message",function(a){e.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=e.$results.scrollTop(),c=e.$results.get(0).scrollHeight-b+a.deltaY,d=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=e.$results.height();d?(e.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(e.$results.scrollTop(e.$results.get(0).scrollHeight-e.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(c){var d=a(this),f=b.GetData(this,"data");if("true"===d.attr("aria-selected"))return void(e.options.get("multiple")?e.trigger("unselect",{originalEvent:c,data:f}):e.trigger("close",{}));e.trigger("select",{originalEvent:c,data:f})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(c){var d=b.GetData(this,"data");e.getHighlightedResults().removeClass("select2-results__option--highlighted"),e.trigger("results:focus",{data:d,element:a(this)})})},c.prototype.getHighlightedResults=function(){return this.$results.find(".select2-results__option--highlighted")},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),c<=2?this.$results.scrollTop(0):(g>this.$results.outerHeight()||g<0)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var c=a('<span class="select2-selection" role="combobox"  aria-haspopup="true" aria-expanded="false"></span>');return this._tabindex=0,null!=b.GetData(this.$element[0],"old-tabindex")?this._tabindex=b.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),c.attr("title",this.$element.attr("title")),c.attr("tabindex",this._tabindex),this.$selection=c,c},d.prototype.bind=function(a,b){var d=this,e=(a.id,a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),window.setTimeout(function(){d.$selection.focus()},0),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(c){a(document.body).on("mousedown.select2."+c.id,function(c){var d=a(c.target),e=d.closest(".select2");a(".select2.select2-container--open").each(function(){a(this),this!=e[0]&&b.GetData(this,"element").select2("close")})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){b.find(".selection").append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html('<span class="select2-selection__rendered"></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span>'),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()})},e.prototype.clear=function(){var a=this.$selection.find(".select2-selection__rendered");a.empty(),a.removeAttr("title")},e.prototype.display=function(a,b){var c=this.options.get("templateSelection");return this.options.get("escapeMarkup")(c(a,b))},e.prototype.selectionContainer=function(){return a("<span></span>")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.attr("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('<ul class="select2-selection__rendered"></ul>'),a},d.prototype.bind=function(b,e){var f=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){f.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!f.options.get("disabled")){var d=a(this),e=d.parent(),g=c.GetData(e[0],"data");f.trigger("unselect",{originalEvent:b,data:g})}})},d.prototype.clear=function(){var a=this.$selection.find(".select2-selection__rendered");a.empty(),a.removeAttr("title")},d.prototype.display=function(a,b){var c=this.options.get("templateSelection");return this.options.get("escapeMarkup")(c(a,b))},d.prototype.selectionContainer=function(){return a('<li class="select2-selection__choice"><span class="select2-selection__choice__remove" role="presentation">&times;</span></li>')},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d<a.length;d++){var e=a[d],f=this.selectionContainer(),g=this.display(e,f);f.append(g),f.attr("title",e.title||e.text),c.StoreData(f[0],"data",e),b.push(f)}var h=this.$selection.find(".select2-selection__rendered");c.appendMany(h,b)}},d}),b.define("select2/selection/placeholder",["../utils"],function(a){function b(a,b,c){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c)}return b.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},b.prototype.createPlaceholder=function(a,b){var c=this.selectionContainer();return c.html(this.display(b)),c.addClass("select2-selection__placeholder").removeClass("select2-selection__choice"),c},b.prototype.update=function(a,b){var c=1==b.length&&b[0].id!=this.placeholder.id;if(b.length>1||c)return a.call(this,b);this.clear();var d=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(d)},b}),b.define("select2/selection/allowClear",["jquery","../keys","../utils"],function(a,b,c){function d(){}return d.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},d.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var d=this.$selection.find(".select2-selection__clear");if(0!==d.length){b.stopPropagation();var e=c.GetData(d[0],"data"),f=this.$element.val();this.$element.val(this.placeholder.id);var g={data:e};if(this.trigger("clear",g),g.prevented)return void this.$element.val(f);for(var h=0;h<e.length;h++)if(g={data:e[h]},this.trigger("unselect",g),g.prevented)return void this.$element.val(f);this.$element.trigger("change"),this.trigger("toggle",{})}}},d.prototype._handleKeyboardClear=function(a,c,d){d.isOpen()||c.which!=b.DELETE&&c.which!=b.BACKSPACE||this._handleClear(c)},d.prototype.update=function(b,d){if(b.call(this,d),!(this.$selection.find(".select2-selection__placeholder").length>0||0===d.length)){var e=a('<span class="select2-selection__clear">&times;</span>');c.StoreData(e[0],"data",d),this.$selection.find(".select2-selection__rendered").prepend(e)}},d}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('<li class="select2-search select2-search--inline"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" aria-autocomplete="list" /></li>');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,d,e){var f=this;a.call(this,d,e),d.on("open",function(){f.$search.trigger("focus")}),d.on("close",function(){f.$search.val(""),f.$search.removeAttr("aria-activedescendant"),f.$search.trigger("focus")}),d.on("enable",function(){f.$search.prop("disabled",!1),f._transferTabIndex()}),d.on("disable",function(){f.$search.prop("disabled",!0)}),d.on("focus",function(a){f.$search.trigger("focus")}),d.on("results:focus",function(a){f.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){f.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){f._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){if(a.stopPropagation(),f.trigger("keypress",a),f._keyUpPrevented=a.isDefaultPrevented(),a.which===c.BACKSPACE&&""===f.$search.val()){var d=f.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var e=b.GetData(d[0],"data");f.searchRemoveChoice(e),a.preventDefault()}}});var g=document.documentMode,h=g&&g<=11;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){if(h)return void f.$selection.off("input.search input.searchcheck");f.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(h&&"input"===a.type)return void f.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&f.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;if(this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c){this.$element.find("[data-select2-tag]").length?this.$element.focus():this.$search.focus()}},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{a=.75*(this.$search.val().length+1)+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting","clear","clearing"],g=["opening","closing","selecting","unselecting","clearing"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){return{"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"}}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),null!=c.id?d+="-"+c.id.toString():d+="-"+a.generateChars(4),d},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f<a.length;f++){var g=a[f].id;-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")});else{var d=a.id;this.$element.val(d),this.$element.trigger("change")}},d.prototype.unselect=function(a){var b=this;if(this.$element.prop("multiple")){if(a.selected=!1,c(a.element).is("option"))return a.element.selected=!1,void this.$element.trigger("change");this.current(function(d){for(var e=[],f=0;f<d.length;f++){var g=d[f].id;g!==a.id&&-1===c.inArray(g,e)&&e.push(g)}b.$element.val(e),b.$element.trigger("change")})}},d.prototype.bind=function(a,b){var c=this;this.container=a,a.on("select",function(a){c.select(a.data)}),a.on("unselect",function(a){c.unselect(a.data)})},d.prototype.destroy=function(){this.$element.find("*").each(function(){b.RemoveData(this)})},d.prototype.query=function(a,b){var d=[],e=this;this.$element.children().each(function(){var b=c(this);if(b.is("option")||b.is("optgroup")){var f=e.item(b),g=e.matches(a,f);null!==g&&d.push(g)}}),b({results:d})},d.prototype.addOptions=function(a){b.appendMany(this.$element,a)},d.prototype.option=function(a){var d;a.children?(d=document.createElement("optgroup"),d.label=a.text):(d=document.createElement("option"),void 0!==d.textContent?d.textContent=a.text:d.innerText=a.text),void 0!==a.id&&(d.value=a.id),a.disabled&&(d.disabled=!0),a.selected&&(d.selected=!0),a.title&&(d.title=a.title);var e=c(d),f=this._normalizeItem(a);return f.element=d,b.StoreData(d,"data",f),e},d.prototype.item=function(a){var d={};if(null!=(d=b.GetData(a[0],"data")))return d;if(a.is("option"))d={id:a.val(),text:a.text(),disabled:a.prop("disabled"),selected:a.prop("selected"),title:a.prop("title")};else if(a.is("optgroup")){d={text:a.prop("label"),children:[],title:a.prop("title")};for(var e=a.children("option"),f=[],g=0;g<e.length;g++){var h=c(e[g]),i=this.item(h);f.push(i)}d.children=f}return d=this._normalizeItem(d),d.element=a[0],b.StoreData(a[0],"data",d),d},d.prototype._normalizeItem=function(a){a!==Object(a)&&(a={id:a,text:a}),a=c.extend({},{text:""},a);var b={selected:!1,disabled:!1};return null!=a.id&&(a.id=a.id.toString()),null!=a.text&&(a.text=a.text.toString()),null==a._resultId&&a.id&&null!=this.container&&(a._resultId=this.generateResultId(this.container,a)),c.extend({},b,a)},d.prototype.matches=function(a,b){return this.options.get("matcher")(a,b)},d}),b.define("select2/data/array",["./select","../utils","jquery"],function(a,b,c){function d(a,b){var c=b.get("data")||[];d.__super__.constructor.call(this,a,b),this.addOptions(this.convertToOptions(c))}return b.Extend(d,a),d.prototype.select=function(a){var b=this.$element.find("option").filter(function(b,c){return c.value==a.id.toString()});0===b.length&&(b=this.option(a),this.addOptions(b)),d.__super__.select.call(this,a)},d.prototype.convertToOptions=function(a){function d(a){return function(){return c(this).val()==a.id}}for(var e=this,f=this.$element.find("option"),g=f.map(function(){return e.item(c(this)).id}).get(),h=[],i=0;i<a.length;i++){var j=this._normalizeItem(a[i]);if(c.inArray(j.id,g)>=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){"status"in d&&(0===d.status||"0"===d.status)||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h<e.length;h++){var i=e[h],j=this._normalizeItem(i),k=this.option(j);this.$element.append(k)}}return b.prototype.query=function(a,b,c){function d(a,f){for(var g=a.results,h=0;h<g.length;h++){var i=g[h],j=null!=i.children&&!d({results:i.children},!0);if((i.text||"").toUpperCase()===(b.term||"").toUpperCase()||j)return!f&&(a.data=g,void c(a))}if(f)return!0;var k=e.createTag(b);if(null!=k){var l=e.option(k);l.attr("data-select2-tag",!0),e.addOptions([l]),e.insertTag(g,k)}a.results=g,c(a)}var e=this;if(this._removeOldTags(),null==b.term||null!=b.page)return void a.call(this,b,c);a.call(this,b,d)},b.prototype.createTag=function(b,c){var d=a.trim(c.term);return""===d?null:{id:d,text:d}},b.prototype.insertTag=function(a,b,c){b.unshift(c)},b.prototype._removeOldTags=function(b){this._lastTag;this.$element.find("option[data-select2-tag]").each(function(){this.selected||a(this).remove()})},b}),b.define("select2/data/tokenizer",["jquery"],function(a){function b(a,b,c){var d=c.get("tokenizer");void 0!==d&&(this.tokenizer=d),a.call(this,b,c)}return b.prototype.bind=function(a,b,c){a.call(this,b,c),this.$search=b.dropdown.$search||b.selection.$search||c.find(".select2-search__field")},b.prototype.query=function(b,c,d){function e(b){var c=g._normalizeItem(b);if(!g.$element.find("option").filter(function(){return a(this).val()===c.id}).length){var d=g.option(c);d.attr("data-select2-tag",!0),g._removeOldTags(),g.addOptions([d])}f(c)}function f(a){g.trigger("select",{data:a})}var g=this;c.term=c.term||"";var h=this.tokenizer(c,this.options,e);h.term!==c.term&&(this.$search.length&&(this.$search.val(h.term),this.$search.focus()),c.term=h.term),b.call(this,c,d)},b.prototype.tokenizer=function(b,c,d,e){for(var f=d.get("tokenSeparators")||[],g=c.term,h=0,i=this.createTag||function(a){return{id:a.term,text:a.term}};h<g.length;){var j=g[h];if(-1!==a.inArray(j,f)){var k=g.substr(0,h),l=a.extend({},c,{term:k}),m=i(l);null!=m?(e(m),g=g.substr(h+1)||"",h=0):h++}else h++}return{term:g}},b}),b.define("select2/data/minimumInputLength",[],function(){function a(a,b,c){this.minimumInputLength=c.get("minimumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){if(b.term=b.term||"",b.term.length<this.minimumInputLength)return void this.trigger("results:message",{message:"inputTooShort",args:{minimum:this.minimumInputLength,input:b.term,params:b}});a.call(this,b,c)},a}),b.define("select2/data/maximumInputLength",[],function(){function a(a,b,c){this.maximumInputLength=c.get("maximumInputLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){if(b.term=b.term||"",this.maximumInputLength>0&&b.term.length>this.maximumInputLength)return void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}});a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;if(d.maximumSelectionLength>0&&f>=d.maximumSelectionLength)return void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}});a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('<span class="select2-dropdown"><span class="select2-results"></span></span>');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('<span class="select2-search select2-search--dropdown"><input class="select2-search__field" type="search" tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false" role="textbox" /></span>');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val(""),e.$search.blur()}),c.on("focus",function(){c.isOpen()||e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){e.showSearch(a)?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){e.$results.offset().top+e.$results.outerHeight(!1)+50>=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1)&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('<li class="select2-results__option select2-results__option--load-more"role="treeitem" aria-disabled="true"></li>'),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a("<span></span>"),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){b.StoreData(this,"select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(c){var d=b.GetData(this,"select2-scroll-position");a(this).scrollTop(d.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id;this.$container.parents().filter(b.hasScroll).off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.top<f.top-h.height,k=i.bottom>f.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d<b.length;d++){var e=b[d];e.children?c+=a(e.children):c++}return c}function b(a,b,c,d){this.minimumResultsForSearch=c.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),a.call(this,b,c,d)}return b.prototype.showSearch=function(b,c){return!(a(c.data.results)<this.minimumResultsForSearch)&&b.call(this,c)},b}),b.define("select2/dropdown/selectOnClose",["../utils"],function(a){function b(){}return b.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("close",function(a){d._handleSelectOnClose(a)})},b.prototype._handleSelectOnClose=function(b,c){if(c&&null!=c.originalSelect2Event){var d=c.originalSelect2Event;if("select"===d._type||"unselect"===d._type)return}var e=this.getHighlightedResults();if(!(e.length<1)){var f=a.GetData(e[0],"data");null!=f.element&&f.element.selected||null==f.element&&f.selected||this.trigger("select",{data:f})}},b}),b.define("select2/dropdown/closeOnSelect",[],function(){function a(){}return a.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),b.on("select",function(a){d._selectTriggered(a)}),b.on("unselect",function(a){d._selectTriggered(a)})},a.prototype._selectTriggered=function(a,b){var c=b.originalEvent;c&&c.ctrlKey||this.trigger("close",{originalEvent:c,originalSelect2Event:b})},a}),b.define("select2/i18n/en",[],function(){return{errorLoading:function(){return"The results could not be loaded."},inputTooLong:function(a){var b=a.input.length-a.maximum,c="Please delete "+b+" character";return 1!=b&&(c+="s"),c},inputTooShort:function(a){return"Please enter "+(a.minimum-a.input.length)+" or more characters"},loadingMore:function(){return"Loading more results…"},maximumSelected:function(a){var b="You can only select "+a.maximum+" item";return 1!=a.maximum&&(b+="s"),b},noResults:function(){return"No results found"},searching:function(){return"Searching…"}}}),b.define("select2/defaults",["jquery","require","./results","./selection/single","./selection/multiple","./selection/placeholder","./selection/allowClear","./selection/search","./selection/eventRelay","./utils","./translation","./diacritics","./data/select","./data/array","./data/ajax","./data/tags","./data/tokenizer","./data/minimumInputLength","./data/maximumInputLength","./data/maximumSelectionLength","./dropdown","./dropdown/search","./dropdown/hidePlaceholder","./dropdown/infiniteScroll","./dropdown/attachBody","./dropdown/minimumResultsForSearch","./dropdown/selectOnClose","./dropdown/closeOnSelect","./i18n/en"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C){function D(){this.reset()}return D.prototype.apply=function(l){if(l=a.extend(!0,{},this.defaults,l),null==l.dataAdapter){if(null!=l.ajax?l.dataAdapter=o:null!=l.data?l.dataAdapter=n:l.dataAdapter=m,l.minimumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),null==l.tokenSeparators&&null==l.tokenizer||(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L<K.length;L++){var M=K[L],N={};try{N=k.loadPath(M)}catch(a){try{M=this.defaults.amdLanguageBase+M,N=k.loadPath(M)}catch(a){l.debug&&window.console&&console.warn&&console.warn('Select2: The language file for "'+M+'" could not be automatically loaded. A fallback will be used instead.');continue}}J.extend(N)}l.translations=J}else{var O=k.loadPath(this.defaults.amdLanguageBase+"en"),P=new k(l.language);P.extend(O),l.translations=P}return l},D.prototype.reset=function(){function b(a){function b(a){return l[a]||a}return a.replace(/[^\u0000-\u007E]/g,b)}function c(d,e){if(""===a.trim(d.term))return e;if(e.children&&e.children.length>0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){null==c(d,e.children[g])&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var h=b(e.text).toUpperCase(),i=b(d.term).toUpperCase();return h.indexOf(i)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(!0,this.defaults,f)},new D}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),d.GetData(a[0],"select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),d.StoreData(a[0],"data",d.GetData(a[0],"select2Tags")),d.StoreData(a[0],"tags",!0)),d.GetData(a[0],"ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",d.GetData(a[0],"ajaxUrl")),d.StoreData(a[0],"ajax-Url",d.GetData(a[0],"ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,d.GetData(a[0])):d.GetData(a[0]);var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,d){null!=c.GetData(a[0],"select2")&&c.GetData(a[0],"select2").destroy(),this.$element=a,this.id=this._generateId(a),d=d||{},this.options=new b(d,a),e.__super__.constructor.call(this);var f=a.attr("tabindex")||0;c.StoreData(a[0],"old-tabindex",f),a.attr("tabindex","-1");var g=this.options.get("dataAdapter");this.dataAdapter=new g(a,this.options);var h=this.render();this._placeContainer(h);var i=this.options.get("selectionAdapter");this.selection=new i(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,h);var j=this.options.get("dropdownAdapter");this.dropdown=new j(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,h);var k=this.options.get("resultsAdapter");this.results=new k(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var l=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){l.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),c.StoreData(a[0],"select2",this),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return e<=0?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;h<i;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e<b.addedNodes.length;e++){var f=b.addedNodes[e];f.selected&&(c=!0)}else b.removedNodes&&b.removedNodes.length>0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting",clear:"clearing"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),null!=a&&0!==a.length||(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",c.GetData(this.$element[0],"old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),c.RemoveData(this.$element[0]),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('<span class="select2 select2-container"><span class="selection"></span><span class="dropdown-wrapper" aria-hidden="true"></span></span>');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),c.StoreData(b[0],"element",this.$element),b},e}),b.define("select2/compat/utils",["jquery"],function(a){function b(b,c,d){var e,f,g=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0===this.indexOf("select2-")&&g.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(f=d(this))&&g.push(f)})),b.attr("class",g.join(" "))}return{syncCssClasses:b}}),b.define("select2/compat/containerCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("containerCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptContainerCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("containerCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/dropdownCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("dropdownCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptDropdownCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("dropdownCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/initSelection",["jquery"],function(a){function b(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=c.get("initSelection"),this._isInitialized=!1,a.call(this,b,c)}return b.prototype.current=function(b,c){var d=this;if(this._isInitialized)return void b.call(this,c);this.initSelection.call(null,this.$element,function(b){d._isInitialized=!0,a.isArray(b)||(b=[b]),c(b)})},b}),b.define("select2/compat/inputData",["jquery","../utils"],function(a,b){function c(a,b,c){this._currentData=[],this._valueSeparator=c.get("valueSeparator")||",","hidden"===b.prop("type")&&c.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `<select>` element instead."),a.call(this,b,c)}return c.prototype.current=function(b,c){function d(b,c){var e=[];return b.selected||-1!==a.inArray(b.id,c)?(b.selected=!0,e.push(b)):b.selected=!1,b.children&&e.push.apply(e,d(b.children,c)),e}for(var e=[],f=0;f<this._currentData.length;f++){var g=this._currentData[f];e.push.apply(e,d(g,this.$element.val().split(this._valueSeparator)))}c(e)},c.prototype.select=function(b,c){if(this.options.get("multiple")){var d=this.$element.val();d+=this._valueSeparator+c.id,this.$element.val(d),this.$element.trigger("change")}else this.current(function(b){a.map(b,function(a){a.selected=!1})}),this.$element.val(c.id),this.$element.trigger("change")},c.prototype.unselect=function(a,b){var c=this;b.selected=!1,this.current(function(a){for(var d=[],e=0;e<a.length;e++){var f=a[e];b.id!=f.id&&d.push(f.id)}c.$element.val(d.join(c._valueSeparator)),c.$element.trigger("change")})},c.prototype.query=function(a,b,c){for(var d=[],e=0;e<this._currentData.length;e++){var f=this._currentData[e],g=this.matches(b,f);null!==g&&d.push(g)}c({results:d})},c.prototype.addOptions=function(c,d){var e=a.map(d,function(a){return b.GetData(a[0],"data")});this._currentData.push.apply(this._currentData,e)},c}),b.define("select2/compat/matcher",["jquery"],function(a){function b(b){function c(c,d){var e=a.extend(!0,{},d);if(null==c.term||""===a.trim(c.term))return e;if(d.children){for(var f=d.children.length-1;f>=0;f--){var g=d.children[f];b(c.term,g.text,g)||e.children.splice(f,1)}if(e.children.length>0)return e}return b(c.term,d.text,d)?e:null}return c}return b}),b.define("select2/compat/query",[],function(){function a(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `query` option has been deprecated in favor of a custom data adapter that overrides the `query` method. Support will be removed for the `query` option in future versions of Select2."),a.call(this,b,c)}return a.prototype.query=function(a,b,c){b.callback=c,this.options.get("query").call(null,b)},a}),b.define("select2/dropdown/attachContainer",[],function(){function a(a,b,c){a.call(this,b,c)}return a.prototype.position=function(a,b,c){c.find(".dropdown-wrapper").append(b),b.addClass("select2-dropdown--below"),c.addClass("select2-container--below")},a}),b.define("select2/dropdown/stopPropagation",[],function(){function a(){}return a.prototype.bind=function(a,b,c){a.call(this,b,c);var d=["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"];this.$dropdown.on(d.join(" "),function(a){a.stopPropagation()})},a}),b.define("select2/selection/stopPropagation",[],function(){function a(){}return a.prototype.bind=function(a,b,c){a.call(this,b,c);var d=["blur","change","click","dblclick","focus","focusin","focusout","input","keydown","keyup","keypress","mousedown","mouseenter","mouseleave","mousemove","mouseover","mouseup","search","touchend","touchstart"];this.$selection.on(d.join(" "),function(a){a.stopPropagation()})},a}),function(c){"function"==typeof b.define&&b.define.amd?b.define("jquery-mousewheel",["jquery"],c):"object"==typeof exports?module.exports=c:c(a)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||n<f)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120==0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}),b.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(a,b,c,d,e){if(null==a.fn.select2){var f=["open","close","destroy"];a.fn.select2=function(b){if("object"==typeof(b=b||{}))return this.each(function(){var d=a.extend(!0,{},b);new c(a(this),d)}),this;if("string"==typeof b){var d,g=Array.prototype.slice.call(arguments,1);return this.each(function(){var a=e.GetData(this,"select2");null==a&&window.console&&console.error&&console.error("The select2('"+b+"') method was called on an element that is not using Select2."),d=a[b].apply(a,g)}),a.inArray(b,f)>-1?this:d}throw new Error("Invalid arguments for Select2: "+b)}}return null==a.fn.select2.defaults&&(a.fn.select2.defaults=d),c}),{define:b.define,require:b.require}}(),c=b.require("jquery.select2");return a.fn.select2.amd=b,c});assets/js/libs/select2.js000064400000504411152425717710011332 0ustar00/*!
 * Select2 4.0.6-rc.1
 * https://select2.github.io
 *
 * Released under the MIT license
 * https://github.com/select2/select2/blob/master/LICENSE.md
 */
;(function (factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(['jquery'], factory);
  } else if (typeof module === 'object' && module.exports) {
    // Node/CommonJS
    module.exports = function (root, jQuery) {
      if (jQuery === undefined) {
        // require('jQuery') returns a factory that requires window to
        // build a jQuery instance, we normalize how we use modules
        // that require this pattern but the window provided is a noop
        // if it's defined (how jquery works)
        if (typeof window !== 'undefined') {
          jQuery = require('jquery');
        }
        else {
          jQuery = require('jquery')(root);
        }
      }
      factory(jQuery);
      return jQuery;
    };
  } else {
    // Browser globals
    factory(jQuery);
  }
} (function (jQuery) {
  // This is needed so we can catch the AMD loader configuration and use it
  // The inner file should be wrapped (by `banner.start.js`) in a function that
  // returns the AMD loader references.
  var S2 =(function () {
  // Restore the Select2 AMD loader so it can be used
  // Needed mostly in the language files, where the loader is not inserted
  if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) {
    var S2 = jQuery.fn.select2.amd;
  }
var S2;(function () { if (!S2 || !S2.requirejs) {
if (!S2) { S2 = {}; } else { require = S2; }
/**
 * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
 * Released under MIT license, http://github.com/requirejs/almond/LICENSE
 */
//Going sloppy to avoid 'use strict' string cost, but strict practices should
//be followed.
/*global setTimeout: false */

var requirejs, require, define;
(function (undef) {
    var main, req, makeMap, handlers,
        defined = {},
        waiting = {},
        config = {},
        defining = {},
        hasOwn = Object.prototype.hasOwnProperty,
        aps = [].slice,
        jsSuffixRegExp = /\.js$/;

    function hasProp(obj, prop) {
        return hasOwn.call(obj, prop);
    }

    /**
     * Given a relative module name, like ./something, normalize it to
     * a real name that can be mapped to a path.
     * @param {String} name the relative name
     * @param {String} baseName a real name that the name arg is relative
     * to.
     * @returns {String} normalized name
     */
    function normalize(name, baseName) {
        var nameParts, nameSegment, mapValue, foundMap, lastIndex,
            foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
            baseParts = baseName && baseName.split("/"),
            map = config.map,
            starMap = (map && map['*']) || {};

        //Adjust any relative paths.
        if (name) {
            name = name.split('/');
            lastIndex = name.length - 1;

            // If wanting node ID compatibility, strip .js from end
            // of IDs. Have to do this here, and not in nameToUrl
            // because node allows either .js or non .js to map
            // to same file.
            if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
                name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
            }

            // Starts with a '.' so need the baseName
            if (name[0].charAt(0) === '.' && baseParts) {
                //Convert baseName to array, and lop off the last part,
                //so that . matches that 'directory' and not name of the baseName's
                //module. For instance, baseName of 'one/two/three', maps to
                //'one/two/three.js', but we want the directory, 'one/two' for
                //this normalization.
                normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
                name = normalizedBaseParts.concat(name);
            }

            //start trimDots
            for (i = 0; i < name.length; i++) {
                part = name[i];
                if (part === '.') {
                    name.splice(i, 1);
                    i -= 1;
                } else if (part === '..') {
                    // If at the start, or previous value is still ..,
                    // keep them so that when converted to a path it may
                    // still work when converted to a path, even though
                    // as an ID it is less than ideal. In larger point
                    // releases, may be better to just kick out an error.
                    if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
                        continue;
                    } else if (i > 0) {
                        name.splice(i - 1, 2);
                        i -= 2;
                    }
                }
            }
            //end trimDots

            name = name.join('/');
        }

        //Apply map config if available.
        if ((baseParts || starMap) && map) {
            nameParts = name.split('/');

            for (i = nameParts.length; i > 0; i -= 1) {
                nameSegment = nameParts.slice(0, i).join("/");

                if (baseParts) {
                    //Find the longest baseName segment match in the config.
                    //So, do joins on the biggest to smallest lengths of baseParts.
                    for (j = baseParts.length; j > 0; j -= 1) {
                        mapValue = map[baseParts.slice(0, j).join('/')];

                        //baseName segment has  config, find if it has one for
                        //this name.
                        if (mapValue) {
                            mapValue = mapValue[nameSegment];
                            if (mapValue) {
                                //Match, update name to the new value.
                                foundMap = mapValue;
                                foundI = i;
                                break;
                            }
                        }
                    }
                }

                if (foundMap) {
                    break;
                }

                //Check for a star map match, but just hold on to it,
                //if there is a shorter segment match later in a matching
                //config, then favor over this star map.
                if (!foundStarMap && starMap && starMap[nameSegment]) {
                    foundStarMap = starMap[nameSegment];
                    starI = i;
                }
            }

            if (!foundMap && foundStarMap) {
                foundMap = foundStarMap;
                foundI = starI;
            }

            if (foundMap) {
                nameParts.splice(0, foundI, foundMap);
                name = nameParts.join('/');
            }
        }

        return name;
    }

    function makeRequire(relName, forceSync) {
        return function () {
            //A version of a require function that passes a moduleName
            //value for items that may need to
            //look up paths relative to the moduleName
            var args = aps.call(arguments, 0);

            //If first arg is not require('string'), and there is only
            //one arg, it is the array form without a callback. Insert
            //a null so that the following concat is correct.
            if (typeof args[0] !== 'string' && args.length === 1) {
                args.push(null);
            }
            return req.apply(undef, args.concat([relName, forceSync]));
        };
    }

    function makeNormalize(relName) {
        return function (name) {
            return normalize(name, relName);
        };
    }

    function makeLoad(depName) {
        return function (value) {
            defined[depName] = value;
        };
    }

    function callDep(name) {
        if (hasProp(waiting, name)) {
            var args = waiting[name];
            delete waiting[name];
            defining[name] = true;
            main.apply(undef, args);
        }

        if (!hasProp(defined, name) && !hasProp(defining, name)) {
            throw new Error('No ' + name);
        }
        return defined[name];
    }

    //Turns a plugin!resource to [plugin, resource]
    //with the plugin being undefined if the name
    //did not have a plugin prefix.
    function splitPrefix(name) {
        var prefix,
            index = name ? name.indexOf('!') : -1;
        if (index > -1) {
            prefix = name.substring(0, index);
            name = name.substring(index + 1, name.length);
        }
        return [prefix, name];
    }

    //Creates a parts array for a relName where first part is plugin ID,
    //second part is resource ID. Assumes relName has already been normalized.
    function makeRelParts(relName) {
        return relName ? splitPrefix(relName) : [];
    }

    /**
     * Makes a name map, normalizing the name, and using a plugin
     * for normalization if necessary. Grabs a ref to plugin
     * too, as an optimization.
     */
    makeMap = function (name, relParts) {
        var plugin,
            parts = splitPrefix(name),
            prefix = parts[0],
            relResourceName = relParts[1];

        name = parts[1];

        if (prefix) {
            prefix = normalize(prefix, relResourceName);
            plugin = callDep(prefix);
        }

        //Normalize according
        if (prefix) {
            if (plugin && plugin.normalize) {
                name = plugin.normalize(name, makeNormalize(relResourceName));
            } else {
                name = normalize(name, relResourceName);
            }
        } else {
            name = normalize(name, relResourceName);
            parts = splitPrefix(name);
            prefix = parts[0];
            name = parts[1];
            if (prefix) {
                plugin = callDep(prefix);
            }
        }

        //Using ridiculous property names for space reasons
        return {
            f: prefix ? prefix + '!' + name : name, //fullName
            n: name,
            pr: prefix,
            p: plugin
        };
    };

    function makeConfig(name) {
        return function () {
            return (config && config.config && config.config[name]) || {};
        };
    }

    handlers = {
        require: function (name) {
            return makeRequire(name);
        },
        exports: function (name) {
            var e = defined[name];
            if (typeof e !== 'undefined') {
                return e;
            } else {
                return (defined[name] = {});
            }
        },
        module: function (name) {
            return {
                id: name,
                uri: '',
                exports: defined[name],
                config: makeConfig(name)
            };
        }
    };

    main = function (name, deps, callback, relName) {
        var cjsModule, depName, ret, map, i, relParts,
            args = [],
            callbackType = typeof callback,
            usingExports;

        //Use name if no relName
        relName = relName || name;
        relParts = makeRelParts(relName);

        //Call the callback to define the module, if necessary.
        if (callbackType === 'undefined' || callbackType === 'function') {
            //Pull out the defined dependencies and pass the ordered
            //values to the callback.
            //Default to [require, exports, module] if no deps
            deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
            for (i = 0; i < deps.length; i += 1) {
                map = makeMap(deps[i], relParts);
                depName = map.f;

                //Fast path CommonJS standard dependencies.
                if (depName === "require") {
                    args[i] = handlers.require(name);
                } else if (depName === "exports") {
                    //CommonJS module spec 1.1
                    args[i] = handlers.exports(name);
                    usingExports = true;
                } else if (depName === "module") {
                    //CommonJS module spec 1.1
                    cjsModule = args[i] = handlers.module(name);
                } else if (hasProp(defined, depName) ||
                           hasProp(waiting, depName) ||
                           hasProp(defining, depName)) {
                    args[i] = callDep(depName);
                } else if (map.p) {
                    map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
                    args[i] = defined[depName];
                } else {
                    throw new Error(name + ' missing ' + depName);
                }
            }

            ret = callback ? callback.apply(defined[name], args) : undefined;

            if (name) {
                //If setting exports via "module" is in play,
                //favor that over return value and exports. After that,
                //favor a non-undefined return value over exports use.
                if (cjsModule && cjsModule.exports !== undef &&
                        cjsModule.exports !== defined[name]) {
                    defined[name] = cjsModule.exports;
                } else if (ret !== undef || !usingExports) {
                    //Use the return value from the function.
                    defined[name] = ret;
                }
            }
        } else if (name) {
            //May just be an object definition for the module. Only
            //worry about defining if have a module name.
            defined[name] = callback;
        }
    };

    requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
        if (typeof deps === "string") {
            if (handlers[deps]) {
                //callback in this case is really relName
                return handlers[deps](callback);
            }
            //Just return the module wanted. In this scenario, the
            //deps arg is the module name, and second arg (if passed)
            //is just the relName.
            //Normalize module name, if it contains . or ..
            return callDep(makeMap(deps, makeRelParts(callback)).f);
        } else if (!deps.splice) {
            //deps is a config object, not an array.
            config = deps;
            if (config.deps) {
                req(config.deps, config.callback);
            }
            if (!callback) {
                return;
            }

            if (callback.splice) {
                //callback is an array, which means it is a dependency list.
                //Adjust args if there are dependencies
                deps = callback;
                callback = relName;
                relName = null;
            } else {
                deps = undef;
            }
        }

        //Support require(['a'])
        callback = callback || function () {};

        //If relName is a function, it is an errback handler,
        //so remove it.
        if (typeof relName === 'function') {
            relName = forceSync;
            forceSync = alt;
        }

        //Simulate async callback;
        if (forceSync) {
            main(undef, deps, callback, relName);
        } else {
            //Using a non-zero value because of concern for what old browsers
            //do, and latest browsers "upgrade" to 4 if lower value is used:
            //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
            //If want a value immediately, use require('id') instead -- something
            //that works in almond on the global level, but not guaranteed and
            //unlikely to work in other AMD implementations.
            setTimeout(function () {
                main(undef, deps, callback, relName);
            }, 4);
        }

        return req;
    };

    /**
     * Just drops the config on the floor, but returns req in case
     * the config return value is used.
     */
    req.config = function (cfg) {
        return req(cfg);
    };

    /**
     * Expose module registry for debugging and tooling
     */
    requirejs._defined = defined;

    define = function (name, deps, callback) {
        if (typeof name !== 'string') {
            throw new Error('See almond README: incorrect module build, no module name');
        }

        //This module may not have dependencies
        if (!deps.splice) {
            //deps is not an array, so probably means
            //an object literal or factory function for
            //the value. Adjust args.
            callback = deps;
            deps = [];
        }

        if (!hasProp(defined, name) && !hasProp(waiting, name)) {
            waiting[name] = [name, deps, callback];
        }
    };

    define.amd = {
        jQuery: true
    };
}());

S2.requirejs = requirejs;S2.require = require;S2.define = define;
}
}());
S2.define("almond", function(){});

/* global jQuery:false, $:false */
S2.define('jquery',[],function () {
  var _$ = jQuery || $;

  if (_$ == null && console && console.error) {
    console.error(
      'Select2: An instance of jQuery or a jQuery-compatible library was not ' +
      'found. Make sure that you are including jQuery before Select2 on your ' +
      'web page.'
    );
  }

  return _$;
});

S2.define('select2/utils',[
  'jquery'
], function ($) {
  var Utils = {};

  Utils.Extend = function (ChildClass, SuperClass) {
    var __hasProp = {}.hasOwnProperty;

    function BaseConstructor () {
      this.constructor = ChildClass;
    }

    for (var key in SuperClass) {
      if (__hasProp.call(SuperClass, key)) {
        ChildClass[key] = SuperClass[key];
      }
    }

    BaseConstructor.prototype = SuperClass.prototype;
    ChildClass.prototype = new BaseConstructor();
    ChildClass.__super__ = SuperClass.prototype;

    return ChildClass;
  };

  function getMethods (theClass) {
    var proto = theClass.prototype;

    var methods = [];

    for (var methodName in proto) {
      var m = proto[methodName];

      if (typeof m !== 'function') {
        continue;
      }

      if (methodName === 'constructor') {
        continue;
      }

      methods.push(methodName);
    }

    return methods;
  }

  Utils.Decorate = function (SuperClass, DecoratorClass) {
    var decoratedMethods = getMethods(DecoratorClass);
    var superMethods = getMethods(SuperClass);

    function DecoratedClass () {
      var unshift = Array.prototype.unshift;

      var argCount = DecoratorClass.prototype.constructor.length;

      var calledConstructor = SuperClass.prototype.constructor;

      if (argCount > 0) {
        unshift.call(arguments, SuperClass.prototype.constructor);

        calledConstructor = DecoratorClass.prototype.constructor;
      }

      calledConstructor.apply(this, arguments);
    }

    DecoratorClass.displayName = SuperClass.displayName;

    function ctr () {
      this.constructor = DecoratedClass;
    }

    DecoratedClass.prototype = new ctr();

    for (var m = 0; m < superMethods.length; m++) {
      var superMethod = superMethods[m];

      DecoratedClass.prototype[superMethod] =
        SuperClass.prototype[superMethod];
    }

    var calledMethod = function (methodName) {
      // Stub out the original method if it's not decorating an actual method
      var originalMethod = function () {};

      if (methodName in DecoratedClass.prototype) {
        originalMethod = DecoratedClass.prototype[methodName];
      }

      var decoratedMethod = DecoratorClass.prototype[methodName];

      return function () {
        var unshift = Array.prototype.unshift;

        unshift.call(arguments, originalMethod);

        return decoratedMethod.apply(this, arguments);
      };
    };

    for (var d = 0; d < decoratedMethods.length; d++) {
      var decoratedMethod = decoratedMethods[d];

      DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
    }

    return DecoratedClass;
  };

  var Observable = function () {
    this.listeners = {};
  };

  Observable.prototype.on = function (event, callback) {
    this.listeners = this.listeners || {};

    if (event in this.listeners) {
      this.listeners[event].push(callback);
    } else {
      this.listeners[event] = [callback];
    }
  };

  Observable.prototype.trigger = function (event) {
    var slice = Array.prototype.slice;
    var params = slice.call(arguments, 1);

    this.listeners = this.listeners || {};

    // Params should always come in as an array
    if (params == null) {
      params = [];
    }

    // If there are no arguments to the event, use a temporary object
    if (params.length === 0) {
      params.push({});
    }

    // Set the `_type` of the first object to the event
    params[0]._type = event;

    if (event in this.listeners) {
      this.invoke(this.listeners[event], slice.call(arguments, 1));
    }

    if ('*' in this.listeners) {
      this.invoke(this.listeners['*'], arguments);
    }
  };

  Observable.prototype.invoke = function (listeners, params) {
    for (var i = 0, len = listeners.length; i < len; i++) {
      listeners[i].apply(this, params);
    }
  };

  Utils.Observable = Observable;

  Utils.generateChars = function (length) {
    var chars = '';

    for (var i = 0; i < length; i++) {
      var randomChar = Math.floor(Math.random() * 36);
      chars += randomChar.toString(36);
    }

    return chars;
  };

  Utils.bind = function (func, context) {
    return function () {
      func.apply(context, arguments);
    };
  };

  Utils._convertData = function (data) {
    for (var originalKey in data) {
      var keys = originalKey.split('-');

      var dataLevel = data;

      if (keys.length === 1) {
        continue;
      }

      for (var k = 0; k < keys.length; k++) {
        var key = keys[k];

        // Lowercase the first letter
        // By default, dash-separated becomes camelCase
        key = key.substring(0, 1).toLowerCase() + key.substring(1);

        if (!(key in dataLevel)) {
          dataLevel[key] = {};
        }

        if (k == keys.length - 1) {
          dataLevel[key] = data[originalKey];
        }

        dataLevel = dataLevel[key];
      }

      delete data[originalKey];
    }

    return data;
  };

  Utils.hasScroll = function (index, el) {
    // Adapted from the function created by @ShadowScripter
    // and adapted by @BillBarry on the Stack Exchange Code Review website.
    // The original code can be found at
    // http://codereview.stackexchange.com/q/13338
    // and was designed to be used with the Sizzle selector engine.

    var $el = $(el);
    var overflowX = el.style.overflowX;
    var overflowY = el.style.overflowY;

    //Check both x and y declarations
    if (overflowX === overflowY &&
        (overflowY === 'hidden' || overflowY === 'visible')) {
      return false;
    }

    if (overflowX === 'scroll' || overflowY === 'scroll') {
      return true;
    }

    return ($el.innerHeight() < el.scrollHeight ||
      $el.innerWidth() < el.scrollWidth);
  };

  Utils.escapeMarkup = function (markup) {
    var replaceMap = {
      '\\': '&#92;',
      '&': '&amp;',
      '<': '&lt;',
      '>': '&gt;',
      '"': '&quot;',
      '\'': '&#39;',
      '/': '&#47;'
    };

    // Do not try to escape the markup if it's not a string
    if (typeof markup !== 'string') {
      return markup;
    }

    return String(markup).replace(/[&<>"'\/\\]/g, function (match) {
      return replaceMap[match];
    });
  };

  // Append an array of jQuery nodes to a given element.
  Utils.appendMany = function ($element, $nodes) {
    // jQuery 1.7.x does not support $.fn.append() with an array
    // Fall back to a jQuery object collection using $.fn.add()
    if ($.fn.jquery.substr(0, 3) === '1.7') {
      var $jqNodes = $();

      $.map($nodes, function (node) {
        $jqNodes = $jqNodes.add(node);
      });

      $nodes = $jqNodes;
    }

    $element.append($nodes);
  };

  // Cache objects in Utils.__cache instead of $.data (see #4346)
  Utils.__cache = {};

  var id = 0;
  Utils.GetUniqueElementId = function (element) {
    // Get a unique element Id. If element has no id, 
    // creates a new unique number, stores it in the id 
    // attribute and returns the new id. 
    // If an id already exists, it simply returns it.

    var select2Id = element.getAttribute('data-select2-id');
    if (select2Id == null) {
      // If element has id, use it.
      if (element.id) {
        select2Id = element.id;
        element.setAttribute('data-select2-id', select2Id);
      } else {
        element.setAttribute('data-select2-id', ++id);
        select2Id = id.toString();
      }
    }
    return select2Id;
  };

  Utils.StoreData = function (element, name, value) {
    // Stores an item in the cache for a specified element.
    // name is the cache key.    
    var id = Utils.GetUniqueElementId(element);
    if (!Utils.__cache[id]) {
      Utils.__cache[id] = {};
    }

    Utils.__cache[id][name] = value;
  };

  Utils.GetData = function (element, name) {
    // Retrieves a value from the cache by its key (name)
    // name is optional. If no name specified, return 
    // all cache items for the specified element.
    // and for a specified element.
    var id = Utils.GetUniqueElementId(element);
    if (name) {
      if (Utils.__cache[id]) {
        return Utils.__cache[id][name] != null ? 
	      Utils.__cache[id][name]:
	      $(element).data(name); // Fallback to HTML5 data attribs.
      }
      return $(element).data(name); // Fallback to HTML5 data attribs.
    } else {
      return Utils.__cache[id];			   
    }
  };

  Utils.RemoveData = function (element) {
    // Removes all cached items for a specified element.
    var id = Utils.GetUniqueElementId(element);
    if (Utils.__cache[id] != null) {
      delete Utils.__cache[id];
    }
  };

  return Utils;
});

S2.define('select2/results',[
  'jquery',
  './utils'
], function ($, Utils) {
  function Results ($element, options, dataAdapter) {
    this.$element = $element;
    this.data = dataAdapter;
    this.options = options;

    Results.__super__.constructor.call(this);
  }

  Utils.Extend(Results, Utils.Observable);

  Results.prototype.render = function () {
    var $results = $(
      '<ul class="select2-results__options" role="tree"></ul>'
    );

    if (this.options.get('multiple')) {
      $results.attr('aria-multiselectable', 'true');
    }

    this.$results = $results;

    return $results;
  };

  Results.prototype.clear = function () {
    this.$results.empty();
  };

  Results.prototype.displayMessage = function (params) {
    var escapeMarkup = this.options.get('escapeMarkup');

    this.clear();
    this.hideLoading();

    var $message = $(
      '<li role="treeitem" aria-live="assertive"' +
      ' class="select2-results__option"></li>'
    );

    var message = this.options.get('translations').get(params.message);

    $message.append(
      escapeMarkup(
        message(params.args)
      )
    );

    $message[0].className += ' select2-results__message';

    this.$results.append($message);
  };

  Results.prototype.hideMessages = function () {
    this.$results.find('.select2-results__message').remove();
  };

  Results.prototype.append = function (data) {
    this.hideLoading();

    var $options = [];

    if (data.results == null || data.results.length === 0) {
      if (this.$results.children().length === 0) {
        this.trigger('results:message', {
          message: 'noResults'
        });
      }

      return;
    }

    data.results = this.sort(data.results);

    for (var d = 0; d < data.results.length; d++) {
      var item = data.results[d];

      var $option = this.option(item);

      $options.push($option);
    }

    this.$results.append($options);
  };

  Results.prototype.position = function ($results, $dropdown) {
    var $resultsContainer = $dropdown.find('.select2-results');
    $resultsContainer.append($results);
  };

  Results.prototype.sort = function (data) {
    var sorter = this.options.get('sorter');

    return sorter(data);
  };

  Results.prototype.highlightFirstItem = function () {
    var $options = this.$results
      .find('.select2-results__option[aria-selected]');

    var $selected = $options.filter('[aria-selected=true]');

    // Check if there are any selected options
    if ($selected.length > 0) {
      // If there are selected options, highlight the first
      $selected.first().trigger('mouseenter');
    } else {
      // If there are no selected options, highlight the first option
      // in the dropdown
      $options.first().trigger('mouseenter');
    }

    this.ensureHighlightVisible();
  };

  Results.prototype.setClasses = function () {
    var self = this;

    this.data.current(function (selected) {
      var selectedIds = $.map(selected, function (s) {
        return s.id.toString();
      });

      var $options = self.$results
        .find('.select2-results__option[aria-selected]');

      $options.each(function () {
        var $option = $(this);

        var item = Utils.GetData(this, 'data');

        // id needs to be converted to a string when comparing
        var id = '' + item.id;

        if ((item.element != null && item.element.selected) ||
            (item.element == null && $.inArray(id, selectedIds) > -1)) {
          $option.attr('aria-selected', 'true');
        } else {
          $option.attr('aria-selected', 'false');
        }
      });

    });
  };

  Results.prototype.showLoading = function (params) {
    this.hideLoading();

    var loadingMore = this.options.get('translations').get('searching');

    var loading = {
      disabled: true,
      loading: true,
      text: loadingMore(params)
    };
    var $loading = this.option(loading);
    $loading.className += ' loading-results';

    this.$results.prepend($loading);
  };

  Results.prototype.hideLoading = function () {
    this.$results.find('.loading-results').remove();
  };

  Results.prototype.option = function (data) {
    var option = document.createElement('li');
    option.className = 'select2-results__option';

    var attrs = {
      'role': 'treeitem',
      'aria-selected': 'false'
    };

    if (data.disabled) {
      delete attrs['aria-selected'];
      attrs['aria-disabled'] = 'true';
    }

    if (data.id == null) {
      delete attrs['aria-selected'];
    }

    if (data._resultId != null) {
      option.id = data._resultId;
    }

    if (data.title) {
      option.title = data.title;
    }

    if (data.children) {
      attrs.role = 'group';
      attrs['aria-label'] = data.text;
      delete attrs['aria-selected'];
    }

    for (var attr in attrs) {
      var val = attrs[attr];

      option.setAttribute(attr, val);
    }

    if (data.children) {
      var $option = $(option);

      var label = document.createElement('strong');
      label.className = 'select2-results__group';

      var $label = $(label);
      this.template(data, label);

      var $children = [];

      for (var c = 0; c < data.children.length; c++) {
        var child = data.children[c];

        var $child = this.option(child);

        $children.push($child);
      }

      var $childrenContainer = $('<ul></ul>', {
        'class': 'select2-results__options select2-results__options--nested'
      });

      $childrenContainer.append($children);

      $option.append(label);
      $option.append($childrenContainer);
    } else {
      this.template(data, option);
    }

    Utils.StoreData(option, 'data', data);

    return option;
  };

  Results.prototype.bind = function (container, $container) {
    var self = this;

    var id = container.id + '-results';

    this.$results.attr('id', id);

    container.on('results:all', function (params) {
      self.clear();
      self.append(params.data);

      if (container.isOpen()) {
        self.setClasses();
        self.highlightFirstItem();
      }
    });

    container.on('results:append', function (params) {
      self.append(params.data);

      if (container.isOpen()) {
        self.setClasses();
      }
    });

    container.on('query', function (params) {
      self.hideMessages();
      self.showLoading(params);
    });

    container.on('select', function () {
      if (!container.isOpen()) {
        return;
      }

      self.setClasses();
      self.highlightFirstItem();
    });

    container.on('unselect', function () {
      if (!container.isOpen()) {
        return;
      }

      self.setClasses();
      self.highlightFirstItem();
    });

    container.on('open', function () {
      // When the dropdown is open, aria-expended="true"
      self.$results.attr('aria-expanded', 'true');
      self.$results.attr('aria-hidden', 'false');

      self.setClasses();
      self.ensureHighlightVisible();
    });

    container.on('close', function () {
      // When the dropdown is closed, aria-expended="false"
      self.$results.attr('aria-expanded', 'false');
      self.$results.attr('aria-hidden', 'true');
      self.$results.removeAttr('aria-activedescendant');
    });

    container.on('results:toggle', function () {
      var $highlighted = self.getHighlightedResults();

      if ($highlighted.length === 0) {
        return;
      }

      $highlighted.trigger('mouseup');
    });

    container.on('results:select', function () {
      var $highlighted = self.getHighlightedResults();

      if ($highlighted.length === 0) {
        return;
      }

      var data = Utils.GetData($highlighted[0], 'data');

      if ($highlighted.attr('aria-selected') == 'true') {
        self.trigger('close', {});
      } else {
        self.trigger('select', {
          data: data
        });
      }
    });

    container.on('results:previous', function () {
      var $highlighted = self.getHighlightedResults();

      var $options = self.$results.find('[aria-selected]');

      var currentIndex = $options.index($highlighted);

      // If we are already at te top, don't move further
      // If no options, currentIndex will be -1
      if (currentIndex <= 0) {
        return;
      }

      var nextIndex = currentIndex - 1;

      // If none are highlighted, highlight the first
      if ($highlighted.length === 0) {
        nextIndex = 0;
      }

      var $next = $options.eq(nextIndex);

      $next.trigger('mouseenter');

      var currentOffset = self.$results.offset().top;
      var nextTop = $next.offset().top;
      var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);

      if (nextIndex === 0) {
        self.$results.scrollTop(0);
      } else if (nextTop - currentOffset < 0) {
        self.$results.scrollTop(nextOffset);
      }
    });

    container.on('results:next', function () {
      var $highlighted = self.getHighlightedResults();

      var $options = self.$results.find('[aria-selected]');

      var currentIndex = $options.index($highlighted);

      var nextIndex = currentIndex + 1;

      // If we are at the last option, stay there
      if (nextIndex >= $options.length) {
        return;
      }

      var $next = $options.eq(nextIndex);

      $next.trigger('mouseenter');

      var currentOffset = self.$results.offset().top +
        self.$results.outerHeight(false);
      var nextBottom = $next.offset().top + $next.outerHeight(false);
      var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;

      if (nextIndex === 0) {
        self.$results.scrollTop(0);
      } else if (nextBottom > currentOffset) {
        self.$results.scrollTop(nextOffset);
      }
    });

    container.on('results:focus', function (params) {
      params.element.addClass('select2-results__option--highlighted');
    });

    container.on('results:message', function (params) {
      self.displayMessage(params);
    });

    if ($.fn.mousewheel) {
      this.$results.on('mousewheel', function (e) {
        var top = self.$results.scrollTop();

        var bottom = self.$results.get(0).scrollHeight - top + e.deltaY;

        var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
        var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();

        if (isAtTop) {
          self.$results.scrollTop(0);

          e.preventDefault();
          e.stopPropagation();
        } else if (isAtBottom) {
          self.$results.scrollTop(
            self.$results.get(0).scrollHeight - self.$results.height()
          );

          e.preventDefault();
          e.stopPropagation();
        }
      });
    }

    this.$results.on('mouseup', '.select2-results__option[aria-selected]',
      function (evt) {
      var $this = $(this);

      var data = Utils.GetData(this, 'data');

      if ($this.attr('aria-selected') === 'true') {
        if (self.options.get('multiple')) {
          self.trigger('unselect', {
            originalEvent: evt,
            data: data
          });
        } else {
          self.trigger('close', {});
        }

        return;
      }

      self.trigger('select', {
        originalEvent: evt,
        data: data
      });
    });

    this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
      function (evt) {
      var data = Utils.GetData(this, 'data');

      self.getHighlightedResults()
          .removeClass('select2-results__option--highlighted');

      self.trigger('results:focus', {
        data: data,
        element: $(this)
      });
    });
  };

  Results.prototype.getHighlightedResults = function () {
    var $highlighted = this.$results
    .find('.select2-results__option--highlighted');

    return $highlighted;
  };

  Results.prototype.destroy = function () {
    this.$results.remove();
  };

  Results.prototype.ensureHighlightVisible = function () {
    var $highlighted = this.getHighlightedResults();

    if ($highlighted.length === 0) {
      return;
    }

    var $options = this.$results.find('[aria-selected]');

    var currentIndex = $options.index($highlighted);

    var currentOffset = this.$results.offset().top;
    var nextTop = $highlighted.offset().top;
    var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);

    var offsetDelta = nextTop - currentOffset;
    nextOffset -= $highlighted.outerHeight(false) * 2;

    if (currentIndex <= 2) {
      this.$results.scrollTop(0);
    } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
      this.$results.scrollTop(nextOffset);
    }
  };

  Results.prototype.template = function (result, container) {
    var template = this.options.get('templateResult');
    var escapeMarkup = this.options.get('escapeMarkup');

    var content = template(result, container);

    if (content == null) {
      container.style.display = 'none';
    } else if (typeof content === 'string') {
      container.innerHTML = escapeMarkup(content);
    } else {
      $(container).append(content);
    }
  };

  return Results;
});

S2.define('select2/keys',[

], function () {
  var KEYS = {
    BACKSPACE: 8,
    TAB: 9,
    ENTER: 13,
    SHIFT: 16,
    CTRL: 17,
    ALT: 18,
    ESC: 27,
    SPACE: 32,
    PAGE_UP: 33,
    PAGE_DOWN: 34,
    END: 35,
    HOME: 36,
    LEFT: 37,
    UP: 38,
    RIGHT: 39,
    DOWN: 40,
    DELETE: 46
  };

  return KEYS;
});

S2.define('select2/selection/base',[
  'jquery',
  '../utils',
  '../keys'
], function ($, Utils, KEYS) {
  function BaseSelection ($element, options) {
    this.$element = $element;
    this.options = options;

    BaseSelection.__super__.constructor.call(this);
  }

  Utils.Extend(BaseSelection, Utils.Observable);

  BaseSelection.prototype.render = function () {
    var $selection = $(
      '<span class="select2-selection" role="combobox" ' +
      ' aria-haspopup="true" aria-expanded="false">' +
      '</span>'
    );

    this._tabindex = 0;

    if (Utils.GetData(this.$element[0], 'old-tabindex') != null) {
      this._tabindex = Utils.GetData(this.$element[0], 'old-tabindex');
    } else if (this.$element.attr('tabindex') != null) {
      this._tabindex = this.$element.attr('tabindex');
    }

    $selection.attr('title', this.$element.attr('title'));
    $selection.attr('tabindex', this._tabindex);

    this.$selection = $selection;

    return $selection;
  };

  BaseSelection.prototype.bind = function (container, $container) {
    var self = this;

    var id = container.id + '-container';
    var resultsId = container.id + '-results';

    this.container = container;

    this.$selection.on('focus', function (evt) {
      self.trigger('focus', evt);
    });

    this.$selection.on('blur', function (evt) {
      self._handleBlur(evt);
    });

    this.$selection.on('keydown', function (evt) {
      self.trigger('keypress', evt);

      if (evt.which === KEYS.SPACE) {
        evt.preventDefault();
      }
    });

    container.on('results:focus', function (params) {
      self.$selection.attr('aria-activedescendant', params.data._resultId);
    });

    container.on('selection:update', function (params) {
      self.update(params.data);
    });

    container.on('open', function () {
      // When the dropdown is open, aria-expanded="true"
      self.$selection.attr('aria-expanded', 'true');
      self.$selection.attr('aria-owns', resultsId);

      self._attachCloseHandler(container);
    });

    container.on('close', function () {
      // When the dropdown is closed, aria-expanded="false"
      self.$selection.attr('aria-expanded', 'false');
      self.$selection.removeAttr('aria-activedescendant');
      self.$selection.removeAttr('aria-owns');

      self.$selection.focus();
      window.setTimeout(function () {
        self.$selection.focus();
      }, 0);

      self._detachCloseHandler(container);
    });

    container.on('enable', function () {
      self.$selection.attr('tabindex', self._tabindex);
    });

    container.on('disable', function () {
      self.$selection.attr('tabindex', '-1');
    });
  };

  BaseSelection.prototype._handleBlur = function (evt) {
    var self = this;

    // This needs to be delayed as the active element is the body when the tab
    // key is pressed, possibly along with others.
    window.setTimeout(function () {
      // Don't trigger `blur` if the focus is still in the selection
      if (
        (document.activeElement == self.$selection[0]) ||
        ($.contains(self.$selection[0], document.activeElement))
      ) {
        return;
      }

      self.trigger('blur', evt);
    }, 1);
  };

  BaseSelection.prototype._attachCloseHandler = function (container) {
    var self = this;

    $(document.body).on('mousedown.select2.' + container.id, function (e) {
      var $target = $(e.target);

      var $select = $target.closest('.select2');

      var $all = $('.select2.select2-container--open');

      $all.each(function () {
        var $this = $(this);

        if (this == $select[0]) {
          return;
        }

        var $element = Utils.GetData(this, 'element');

        $element.select2('close');
      });
    });
  };

  BaseSelection.prototype._detachCloseHandler = function (container) {
    $(document.body).off('mousedown.select2.' + container.id);
  };

  BaseSelection.prototype.position = function ($selection, $container) {
    var $selectionContainer = $container.find('.selection');
    $selectionContainer.append($selection);
  };

  BaseSelection.prototype.destroy = function () {
    this._detachCloseHandler(this.container);
  };

  BaseSelection.prototype.update = function (data) {
    throw new Error('The `update` method must be defined in child classes.');
  };

  return BaseSelection;
});

S2.define('select2/selection/single',[
  'jquery',
  './base',
  '../utils',
  '../keys'
], function ($, BaseSelection, Utils, KEYS) {
  function SingleSelection () {
    SingleSelection.__super__.constructor.apply(this, arguments);
  }

  Utils.Extend(SingleSelection, BaseSelection);

  SingleSelection.prototype.render = function () {
    var $selection = SingleSelection.__super__.render.call(this);

    $selection.addClass('select2-selection--single');

    $selection.html(
      '<span class="select2-selection__rendered"></span>' +
      '<span class="select2-selection__arrow" role="presentation">' +
        '<b role="presentation"></b>' +
      '</span>'
    );

    return $selection;
  };

  SingleSelection.prototype.bind = function (container, $container) {
    var self = this;

    SingleSelection.__super__.bind.apply(this, arguments);

    var id = container.id + '-container';

    this.$selection.find('.select2-selection__rendered')
      .attr('id', id)
      .attr('role', 'textbox')
      .attr('aria-readonly', 'true');
    this.$selection.attr('aria-labelledby', id);

    this.$selection.on('mousedown', function (evt) {
      // Only respond to left clicks
      if (evt.which !== 1) {
        return;
      }

      self.trigger('toggle', {
        originalEvent: evt
      });
    });

    this.$selection.on('focus', function (evt) {
      // User focuses on the container
    });

    this.$selection.on('blur', function (evt) {
      // User exits the container
    });

    container.on('focus', function (evt) {
      if (!container.isOpen()) {
        self.$selection.focus();
      }
    });
  };

  SingleSelection.prototype.clear = function () {
    var $rendered = this.$selection.find('.select2-selection__rendered');
    $rendered.empty();
    $rendered.removeAttr('title'); // clear tooltip on empty
  };

  SingleSelection.prototype.display = function (data, container) {
    var template = this.options.get('templateSelection');
    var escapeMarkup = this.options.get('escapeMarkup');

    return escapeMarkup(template(data, container));
  };

  SingleSelection.prototype.selectionContainer = function () {
    return $('<span></span>');
  };

  SingleSelection.prototype.update = function (data) {
    if (data.length === 0) {
      this.clear();
      return;
    }

    var selection = data[0];

    var $rendered = this.$selection.find('.select2-selection__rendered');
    var formatted = this.display(selection, $rendered);

    $rendered.empty().append(formatted);
    $rendered.attr('title', selection.title || selection.text);
  };

  return SingleSelection;
});

S2.define('select2/selection/multiple',[
  'jquery',
  './base',
  '../utils'
], function ($, BaseSelection, Utils) {
  function MultipleSelection ($element, options) {
    MultipleSelection.__super__.constructor.apply(this, arguments);
  }

  Utils.Extend(MultipleSelection, BaseSelection);

  MultipleSelection.prototype.render = function () {
    var $selection = MultipleSelection.__super__.render.call(this);

    $selection.addClass('select2-selection--multiple');

    $selection.html(
      '<ul class="select2-selection__rendered"></ul>'
    );

    return $selection;
  };

  MultipleSelection.prototype.bind = function (container, $container) {
    var self = this;

    MultipleSelection.__super__.bind.apply(this, arguments);

    this.$selection.on('click', function (evt) {
      self.trigger('toggle', {
        originalEvent: evt
      });
    });

    this.$selection.on(
      'click',
      '.select2-selection__choice__remove',
      function (evt) {
        // Ignore the event if it is disabled
        if (self.options.get('disabled')) {
          return;
        }

        var $remove = $(this);
        var $selection = $remove.parent();

        var data = Utils.GetData($selection[0], 'data');

        self.trigger('unselect', {
          originalEvent: evt,
          data: data
        });
      }
    );
  };

  MultipleSelection.prototype.clear = function () {
    var $rendered = this.$selection.find('.select2-selection__rendered');
    $rendered.empty();
    $rendered.removeAttr('title');
  };

  MultipleSelection.prototype.display = function (data, container) {
    var template = this.options.get('templateSelection');
    var escapeMarkup = this.options.get('escapeMarkup');

    return escapeMarkup(template(data, container));
  };

  MultipleSelection.prototype.selectionContainer = function () {
    var $container = $(
      '<li class="select2-selection__choice">' +
        '<span class="select2-selection__choice__remove" role="presentation">' +
          '&times;' +
        '</span>' +
      '</li>'
    );

    return $container;
  };

  MultipleSelection.prototype.update = function (data) {
    this.clear();

    if (data.length === 0) {
      return;
    }

    var $selections = [];

    for (var d = 0; d < data.length; d++) {
      var selection = data[d];

      var $selection = this.selectionContainer();
      var formatted = this.display(selection, $selection);

      $selection.append(formatted);
      $selection.attr('title', selection.title || selection.text);

      Utils.StoreData($selection[0], 'data', selection);

      $selections.push($selection);
    }

    var $rendered = this.$selection.find('.select2-selection__rendered');

    Utils.appendMany($rendered, $selections);
  };

  return MultipleSelection;
});

S2.define('select2/selection/placeholder',[
  '../utils'
], function (Utils) {
  function Placeholder (decorated, $element, options) {
    this.placeholder = this.normalizePlaceholder(options.get('placeholder'));

    decorated.call(this, $element, options);
  }

  Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
    if (typeof placeholder === 'string') {
      placeholder = {
        id: '',
        text: placeholder
      };
    }

    return placeholder;
  };

  Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
    var $placeholder = this.selectionContainer();

    $placeholder.html(this.display(placeholder));
    $placeholder.addClass('select2-selection__placeholder')
                .removeClass('select2-selection__choice');

    return $placeholder;
  };

  Placeholder.prototype.update = function (decorated, data) {
    var singlePlaceholder = (
      data.length == 1 && data[0].id != this.placeholder.id
    );
    var multipleSelections = data.length > 1;

    if (multipleSelections || singlePlaceholder) {
      return decorated.call(this, data);
    }

    this.clear();

    var $placeholder = this.createPlaceholder(this.placeholder);

    this.$selection.find('.select2-selection__rendered').append($placeholder);
  };

  return Placeholder;
});

S2.define('select2/selection/allowClear',[
  'jquery',
  '../keys',
  '../utils'
], function ($, KEYS, Utils) {
  function AllowClear () { }

  AllowClear.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    if (this.placeholder == null) {
      if (this.options.get('debug') && window.console && console.error) {
        console.error(
          'Select2: The `allowClear` option should be used in combination ' +
          'with the `placeholder` option.'
        );
      }
    }

    this.$selection.on('mousedown', '.select2-selection__clear',
      function (evt) {
        self._handleClear(evt);
    });

    container.on('keypress', function (evt) {
      self._handleKeyboardClear(evt, container);
    });
  };

  AllowClear.prototype._handleClear = function (_, evt) {
    // Ignore the event if it is disabled
    if (this.options.get('disabled')) {
      return;
    }

    var $clear = this.$selection.find('.select2-selection__clear');

    // Ignore the event if nothing has been selected
    if ($clear.length === 0) {
      return;
    }

    evt.stopPropagation();

    var data = Utils.GetData($clear[0], 'data');

    var previousVal = this.$element.val();
    this.$element.val(this.placeholder.id);

    var unselectData = {
      data: data
    };
    this.trigger('clear', unselectData);
    if (unselectData.prevented) {
      this.$element.val(previousVal);
      return;
    }

    for (var d = 0; d < data.length; d++) {
      unselectData = {
        data: data[d]
      };

      // Trigger the `unselect` event, so people can prevent it from being
      // cleared.
      this.trigger('unselect', unselectData);

      // If the event was prevented, don't clear it out.
      if (unselectData.prevented) {
        this.$element.val(previousVal);
        return;
      }
    }

    this.$element.trigger('change');

    this.trigger('toggle', {});
  };

  AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
    if (container.isOpen()) {
      return;
    }

    if (evt.which == KEYS.DELETE || evt.which == KEYS.BACKSPACE) {
      this._handleClear(evt);
    }
  };

  AllowClear.prototype.update = function (decorated, data) {
    decorated.call(this, data);

    if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
        data.length === 0) {
      return;
    }

    var $remove = $(
      '<span class="select2-selection__clear">' +
        '&times;' +
      '</span>'
    );
    Utils.StoreData($remove[0], 'data', data);

    this.$selection.find('.select2-selection__rendered').prepend($remove);
  };

  return AllowClear;
});

S2.define('select2/selection/search',[
  'jquery',
  '../utils',
  '../keys'
], function ($, Utils, KEYS) {
  function Search (decorated, $element, options) {
    decorated.call(this, $element, options);
  }

  Search.prototype.render = function (decorated) {
    var $search = $(
      '<li class="select2-search select2-search--inline">' +
        '<input class="select2-search__field" type="search" tabindex="-1"' +
        ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
        ' spellcheck="false" role="textbox" aria-autocomplete="list" />' +
      '</li>'
    );

    this.$searchContainer = $search;
    this.$search = $search.find('input');

    var $rendered = decorated.call(this);

    this._transferTabIndex();

    return $rendered;
  };

  Search.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    container.on('open', function () {
      self.$search.trigger('focus');
    });

    container.on('close', function () {
      self.$search.val('');
      self.$search.removeAttr('aria-activedescendant');
      self.$search.trigger('focus');
    });

    container.on('enable', function () {
      self.$search.prop('disabled', false);

      self._transferTabIndex();
    });

    container.on('disable', function () {
      self.$search.prop('disabled', true);
    });

    container.on('focus', function (evt) {
      self.$search.trigger('focus');
    });

    container.on('results:focus', function (params) {
      self.$search.attr('aria-activedescendant', params.id);
    });

    this.$selection.on('focusin', '.select2-search--inline', function (evt) {
      self.trigger('focus', evt);
    });

    this.$selection.on('focusout', '.select2-search--inline', function (evt) {
      self._handleBlur(evt);
    });

    this.$selection.on('keydown', '.select2-search--inline', function (evt) {
      evt.stopPropagation();

      self.trigger('keypress', evt);

      self._keyUpPrevented = evt.isDefaultPrevented();

      var key = evt.which;

      if (key === KEYS.BACKSPACE && self.$search.val() === '') {
        var $previousChoice = self.$searchContainer
          .prev('.select2-selection__choice');

        if ($previousChoice.length > 0) {
          var item = Utils.GetData($previousChoice[0], 'data');

          self.searchRemoveChoice(item);

          evt.preventDefault();
        }
      }
    });

    // Try to detect the IE version should the `documentMode` property that
    // is stored on the document. This is only implemented in IE and is
    // slightly cleaner than doing a user agent check.
    // This property is not available in Edge, but Edge also doesn't have
    // this bug.
    var msie = document.documentMode;
    var disableInputEvents = msie && msie <= 11;

    // Workaround for browsers which do not support the `input` event
    // This will prevent double-triggering of events for browsers which support
    // both the `keyup` and `input` events.
    this.$selection.on(
      'input.searchcheck',
      '.select2-search--inline',
      function (evt) {
        // IE will trigger the `input` event when a placeholder is used on a
        // search box. To get around this issue, we are forced to ignore all
        // `input` events in IE and keep using `keyup`.
        if (disableInputEvents) {
          self.$selection.off('input.search input.searchcheck');
          return;
        }

        // Unbind the duplicated `keyup` event
        self.$selection.off('keyup.search');
      }
    );

    this.$selection.on(
      'keyup.search input.search',
      '.select2-search--inline',
      function (evt) {
        // IE will trigger the `input` event when a placeholder is used on a
        // search box. To get around this issue, we are forced to ignore all
        // `input` events in IE and keep using `keyup`.
        if (disableInputEvents && evt.type === 'input') {
          self.$selection.off('input.search input.searchcheck');
          return;
        }

        var key = evt.which;

        // We can freely ignore events from modifier keys
        if (key == KEYS.SHIFT || key == KEYS.CTRL || key == KEYS.ALT) {
          return;
        }

        // Tabbing will be handled during the `keydown` phase
        if (key == KEYS.TAB) {
          return;
        }

        self.handleSearch(evt);
      }
    );
  };

  /**
   * This method will transfer the tabindex attribute from the rendered
   * selection to the search box. This allows for the search box to be used as
   * the primary focus instead of the selection container.
   *
   * @private
   */
  Search.prototype._transferTabIndex = function (decorated) {
    this.$search.attr('tabindex', this.$selection.attr('tabindex'));
    this.$selection.attr('tabindex', '-1');
  };

  Search.prototype.createPlaceholder = function (decorated, placeholder) {
    this.$search.attr('placeholder', placeholder.text);
  };

  Search.prototype.update = function (decorated, data) {
    var searchHadFocus = this.$search[0] == document.activeElement;

    this.$search.attr('placeholder', '');

    decorated.call(this, data);

    this.$selection.find('.select2-selection__rendered')
                   .append(this.$searchContainer);

    this.resizeSearch();
    if (searchHadFocus) {
      var isTagInput = this.$element.find('[data-select2-tag]').length;
      if (isTagInput) {
        // fix IE11 bug where tag input lost focus
        this.$element.focus();
      } else {
        this.$search.focus();
      }
    }
  };

  Search.prototype.handleSearch = function () {
    this.resizeSearch();

    if (!this._keyUpPrevented) {
      var input = this.$search.val();

      this.trigger('query', {
        term: input
      });
    }

    this._keyUpPrevented = false;
  };

  Search.prototype.searchRemoveChoice = function (decorated, item) {
    this.trigger('unselect', {
      data: item
    });

    this.$search.val(item.text);
    this.handleSearch();
  };

  Search.prototype.resizeSearch = function () {
    this.$search.css('width', '25px');

    var width = '';

    if (this.$search.attr('placeholder') !== '') {
      width = this.$selection.find('.select2-selection__rendered').innerWidth();
    } else {
      var minimumWidth = this.$search.val().length + 1;

      width = (minimumWidth * 0.75) + 'em';
    }

    this.$search.css('width', width);
  };

  return Search;
});

S2.define('select2/selection/eventRelay',[
  'jquery'
], function ($) {
  function EventRelay () { }

  EventRelay.prototype.bind = function (decorated, container, $container) {
    var self = this;
    var relayEvents = [
      'open', 'opening',
      'close', 'closing',
      'select', 'selecting',
      'unselect', 'unselecting',
      'clear', 'clearing'
    ];

    var preventableEvents = [
      'opening', 'closing', 'selecting', 'unselecting', 'clearing'
    ];

    decorated.call(this, container, $container);

    container.on('*', function (name, params) {
      // Ignore events that should not be relayed
      if ($.inArray(name, relayEvents) === -1) {
        return;
      }

      // The parameters should always be an object
      params = params || {};

      // Generate the jQuery event for the Select2 event
      var evt = $.Event('select2:' + name, {
        params: params
      });

      self.$element.trigger(evt);

      // Only handle preventable events if it was one
      if ($.inArray(name, preventableEvents) === -1) {
        return;
      }

      params.prevented = evt.isDefaultPrevented();
    });
  };

  return EventRelay;
});

S2.define('select2/translation',[
  'jquery',
  'require'
], function ($, require) {
  function Translation (dict) {
    this.dict = dict || {};
  }

  Translation.prototype.all = function () {
    return this.dict;
  };

  Translation.prototype.get = function (key) {
    return this.dict[key];
  };

  Translation.prototype.extend = function (translation) {
    this.dict = $.extend({}, translation.all(), this.dict);
  };

  // Static functions

  Translation._cache = {};

  Translation.loadPath = function (path) {
    if (!(path in Translation._cache)) {
      var translations = require(path);

      Translation._cache[path] = translations;
    }

    return new Translation(Translation._cache[path]);
  };

  return Translation;
});

S2.define('select2/diacritics',[

], function () {
  var diacritics = {
    '\u24B6': 'A',
    '\uFF21': 'A',
    '\u00C0': 'A',
    '\u00C1': 'A',
    '\u00C2': 'A',
    '\u1EA6': 'A',
    '\u1EA4': 'A',
    '\u1EAA': 'A',
    '\u1EA8': 'A',
    '\u00C3': 'A',
    '\u0100': 'A',
    '\u0102': 'A',
    '\u1EB0': 'A',
    '\u1EAE': 'A',
    '\u1EB4': 'A',
    '\u1EB2': 'A',
    '\u0226': 'A',
    '\u01E0': 'A',
    '\u00C4': 'A',
    '\u01DE': 'A',
    '\u1EA2': 'A',
    '\u00C5': 'A',
    '\u01FA': 'A',
    '\u01CD': 'A',
    '\u0200': 'A',
    '\u0202': 'A',
    '\u1EA0': 'A',
    '\u1EAC': 'A',
    '\u1EB6': 'A',
    '\u1E00': 'A',
    '\u0104': 'A',
    '\u023A': 'A',
    '\u2C6F': 'A',
    '\uA732': 'AA',
    '\u00C6': 'AE',
    '\u01FC': 'AE',
    '\u01E2': 'AE',
    '\uA734': 'AO',
    '\uA736': 'AU',
    '\uA738': 'AV',
    '\uA73A': 'AV',
    '\uA73C': 'AY',
    '\u24B7': 'B',
    '\uFF22': 'B',
    '\u1E02': 'B',
    '\u1E04': 'B',
    '\u1E06': 'B',
    '\u0243': 'B',
    '\u0182': 'B',
    '\u0181': 'B',
    '\u24B8': 'C',
    '\uFF23': 'C',
    '\u0106': 'C',
    '\u0108': 'C',
    '\u010A': 'C',
    '\u010C': 'C',
    '\u00C7': 'C',
    '\u1E08': 'C',
    '\u0187': 'C',
    '\u023B': 'C',
    '\uA73E': 'C',
    '\u24B9': 'D',
    '\uFF24': 'D',
    '\u1E0A': 'D',
    '\u010E': 'D',
    '\u1E0C': 'D',
    '\u1E10': 'D',
    '\u1E12': 'D',
    '\u1E0E': 'D',
    '\u0110': 'D',
    '\u018B': 'D',
    '\u018A': 'D',
    '\u0189': 'D',
    '\uA779': 'D',
    '\u01F1': 'DZ',
    '\u01C4': 'DZ',
    '\u01F2': 'Dz',
    '\u01C5': 'Dz',
    '\u24BA': 'E',
    '\uFF25': 'E',
    '\u00C8': 'E',
    '\u00C9': 'E',
    '\u00CA': 'E',
    '\u1EC0': 'E',
    '\u1EBE': 'E',
    '\u1EC4': 'E',
    '\u1EC2': 'E',
    '\u1EBC': 'E',
    '\u0112': 'E',
    '\u1E14': 'E',
    '\u1E16': 'E',
    '\u0114': 'E',
    '\u0116': 'E',
    '\u00CB': 'E',
    '\u1EBA': 'E',
    '\u011A': 'E',
    '\u0204': 'E',
    '\u0206': 'E',
    '\u1EB8': 'E',
    '\u1EC6': 'E',
    '\u0228': 'E',
    '\u1E1C': 'E',
    '\u0118': 'E',
    '\u1E18': 'E',
    '\u1E1A': 'E',
    '\u0190': 'E',
    '\u018E': 'E',
    '\u24BB': 'F',
    '\uFF26': 'F',
    '\u1E1E': 'F',
    '\u0191': 'F',
    '\uA77B': 'F',
    '\u24BC': 'G',
    '\uFF27': 'G',
    '\u01F4': 'G',
    '\u011C': 'G',
    '\u1E20': 'G',
    '\u011E': 'G',
    '\u0120': 'G',
    '\u01E6': 'G',
    '\u0122': 'G',
    '\u01E4': 'G',
    '\u0193': 'G',
    '\uA7A0': 'G',
    '\uA77D': 'G',
    '\uA77E': 'G',
    '\u24BD': 'H',
    '\uFF28': 'H',
    '\u0124': 'H',
    '\u1E22': 'H',
    '\u1E26': 'H',
    '\u021E': 'H',
    '\u1E24': 'H',
    '\u1E28': 'H',
    '\u1E2A': 'H',
    '\u0126': 'H',
    '\u2C67': 'H',
    '\u2C75': 'H',
    '\uA78D': 'H',
    '\u24BE': 'I',
    '\uFF29': 'I',
    '\u00CC': 'I',
    '\u00CD': 'I',
    '\u00CE': 'I',
    '\u0128': 'I',
    '\u012A': 'I',
    '\u012C': 'I',
    '\u0130': 'I',
    '\u00CF': 'I',
    '\u1E2E': 'I',
    '\u1EC8': 'I',
    '\u01CF': 'I',
    '\u0208': 'I',
    '\u020A': 'I',
    '\u1ECA': 'I',
    '\u012E': 'I',
    '\u1E2C': 'I',
    '\u0197': 'I',
    '\u24BF': 'J',
    '\uFF2A': 'J',
    '\u0134': 'J',
    '\u0248': 'J',
    '\u24C0': 'K',
    '\uFF2B': 'K',
    '\u1E30': 'K',
    '\u01E8': 'K',
    '\u1E32': 'K',
    '\u0136': 'K',
    '\u1E34': 'K',
    '\u0198': 'K',
    '\u2C69': 'K',
    '\uA740': 'K',
    '\uA742': 'K',
    '\uA744': 'K',
    '\uA7A2': 'K',
    '\u24C1': 'L',
    '\uFF2C': 'L',
    '\u013F': 'L',
    '\u0139': 'L',
    '\u013D': 'L',
    '\u1E36': 'L',
    '\u1E38': 'L',
    '\u013B': 'L',
    '\u1E3C': 'L',
    '\u1E3A': 'L',
    '\u0141': 'L',
    '\u023D': 'L',
    '\u2C62': 'L',
    '\u2C60': 'L',
    '\uA748': 'L',
    '\uA746': 'L',
    '\uA780': 'L',
    '\u01C7': 'LJ',
    '\u01C8': 'Lj',
    '\u24C2': 'M',
    '\uFF2D': 'M',
    '\u1E3E': 'M',
    '\u1E40': 'M',
    '\u1E42': 'M',
    '\u2C6E': 'M',
    '\u019C': 'M',
    '\u24C3': 'N',
    '\uFF2E': 'N',
    '\u01F8': 'N',
    '\u0143': 'N',
    '\u00D1': 'N',
    '\u1E44': 'N',
    '\u0147': 'N',
    '\u1E46': 'N',
    '\u0145': 'N',
    '\u1E4A': 'N',
    '\u1E48': 'N',
    '\u0220': 'N',
    '\u019D': 'N',
    '\uA790': 'N',
    '\uA7A4': 'N',
    '\u01CA': 'NJ',
    '\u01CB': 'Nj',
    '\u24C4': 'O',
    '\uFF2F': 'O',
    '\u00D2': 'O',
    '\u00D3': 'O',
    '\u00D4': 'O',
    '\u1ED2': 'O',
    '\u1ED0': 'O',
    '\u1ED6': 'O',
    '\u1ED4': 'O',
    '\u00D5': 'O',
    '\u1E4C': 'O',
    '\u022C': 'O',
    '\u1E4E': 'O',
    '\u014C': 'O',
    '\u1E50': 'O',
    '\u1E52': 'O',
    '\u014E': 'O',
    '\u022E': 'O',
    '\u0230': 'O',
    '\u00D6': 'O',
    '\u022A': 'O',
    '\u1ECE': 'O',
    '\u0150': 'O',
    '\u01D1': 'O',
    '\u020C': 'O',
    '\u020E': 'O',
    '\u01A0': 'O',
    '\u1EDC': 'O',
    '\u1EDA': 'O',
    '\u1EE0': 'O',
    '\u1EDE': 'O',
    '\u1EE2': 'O',
    '\u1ECC': 'O',
    '\u1ED8': 'O',
    '\u01EA': 'O',
    '\u01EC': 'O',
    '\u00D8': 'O',
    '\u01FE': 'O',
    '\u0186': 'O',
    '\u019F': 'O',
    '\uA74A': 'O',
    '\uA74C': 'O',
    '\u01A2': 'OI',
    '\uA74E': 'OO',
    '\u0222': 'OU',
    '\u24C5': 'P',
    '\uFF30': 'P',
    '\u1E54': 'P',
    '\u1E56': 'P',
    '\u01A4': 'P',
    '\u2C63': 'P',
    '\uA750': 'P',
    '\uA752': 'P',
    '\uA754': 'P',
    '\u24C6': 'Q',
    '\uFF31': 'Q',
    '\uA756': 'Q',
    '\uA758': 'Q',
    '\u024A': 'Q',
    '\u24C7': 'R',
    '\uFF32': 'R',
    '\u0154': 'R',
    '\u1E58': 'R',
    '\u0158': 'R',
    '\u0210': 'R',
    '\u0212': 'R',
    '\u1E5A': 'R',
    '\u1E5C': 'R',
    '\u0156': 'R',
    '\u1E5E': 'R',
    '\u024C': 'R',
    '\u2C64': 'R',
    '\uA75A': 'R',
    '\uA7A6': 'R',
    '\uA782': 'R',
    '\u24C8': 'S',
    '\uFF33': 'S',
    '\u1E9E': 'S',
    '\u015A': 'S',
    '\u1E64': 'S',
    '\u015C': 'S',
    '\u1E60': 'S',
    '\u0160': 'S',
    '\u1E66': 'S',
    '\u1E62': 'S',
    '\u1E68': 'S',
    '\u0218': 'S',
    '\u015E': 'S',
    '\u2C7E': 'S',
    '\uA7A8': 'S',
    '\uA784': 'S',
    '\u24C9': 'T',
    '\uFF34': 'T',
    '\u1E6A': 'T',
    '\u0164': 'T',
    '\u1E6C': 'T',
    '\u021A': 'T',
    '\u0162': 'T',
    '\u1E70': 'T',
    '\u1E6E': 'T',
    '\u0166': 'T',
    '\u01AC': 'T',
    '\u01AE': 'T',
    '\u023E': 'T',
    '\uA786': 'T',
    '\uA728': 'TZ',
    '\u24CA': 'U',
    '\uFF35': 'U',
    '\u00D9': 'U',
    '\u00DA': 'U',
    '\u00DB': 'U',
    '\u0168': 'U',
    '\u1E78': 'U',
    '\u016A': 'U',
    '\u1E7A': 'U',
    '\u016C': 'U',
    '\u00DC': 'U',
    '\u01DB': 'U',
    '\u01D7': 'U',
    '\u01D5': 'U',
    '\u01D9': 'U',
    '\u1EE6': 'U',
    '\u016E': 'U',
    '\u0170': 'U',
    '\u01D3': 'U',
    '\u0214': 'U',
    '\u0216': 'U',
    '\u01AF': 'U',
    '\u1EEA': 'U',
    '\u1EE8': 'U',
    '\u1EEE': 'U',
    '\u1EEC': 'U',
    '\u1EF0': 'U',
    '\u1EE4': 'U',
    '\u1E72': 'U',
    '\u0172': 'U',
    '\u1E76': 'U',
    '\u1E74': 'U',
    '\u0244': 'U',
    '\u24CB': 'V',
    '\uFF36': 'V',
    '\u1E7C': 'V',
    '\u1E7E': 'V',
    '\u01B2': 'V',
    '\uA75E': 'V',
    '\u0245': 'V',
    '\uA760': 'VY',
    '\u24CC': 'W',
    '\uFF37': 'W',
    '\u1E80': 'W',
    '\u1E82': 'W',
    '\u0174': 'W',
    '\u1E86': 'W',
    '\u1E84': 'W',
    '\u1E88': 'W',
    '\u2C72': 'W',
    '\u24CD': 'X',
    '\uFF38': 'X',
    '\u1E8A': 'X',
    '\u1E8C': 'X',
    '\u24CE': 'Y',
    '\uFF39': 'Y',
    '\u1EF2': 'Y',
    '\u00DD': 'Y',
    '\u0176': 'Y',
    '\u1EF8': 'Y',
    '\u0232': 'Y',
    '\u1E8E': 'Y',
    '\u0178': 'Y',
    '\u1EF6': 'Y',
    '\u1EF4': 'Y',
    '\u01B3': 'Y',
    '\u024E': 'Y',
    '\u1EFE': 'Y',
    '\u24CF': 'Z',
    '\uFF3A': 'Z',
    '\u0179': 'Z',
    '\u1E90': 'Z',
    '\u017B': 'Z',
    '\u017D': 'Z',
    '\u1E92': 'Z',
    '\u1E94': 'Z',
    '\u01B5': 'Z',
    '\u0224': 'Z',
    '\u2C7F': 'Z',
    '\u2C6B': 'Z',
    '\uA762': 'Z',
    '\u24D0': 'a',
    '\uFF41': 'a',
    '\u1E9A': 'a',
    '\u00E0': 'a',
    '\u00E1': 'a',
    '\u00E2': 'a',
    '\u1EA7': 'a',
    '\u1EA5': 'a',
    '\u1EAB': 'a',
    '\u1EA9': 'a',
    '\u00E3': 'a',
    '\u0101': 'a',
    '\u0103': 'a',
    '\u1EB1': 'a',
    '\u1EAF': 'a',
    '\u1EB5': 'a',
    '\u1EB3': 'a',
    '\u0227': 'a',
    '\u01E1': 'a',
    '\u00E4': 'a',
    '\u01DF': 'a',
    '\u1EA3': 'a',
    '\u00E5': 'a',
    '\u01FB': 'a',
    '\u01CE': 'a',
    '\u0201': 'a',
    '\u0203': 'a',
    '\u1EA1': 'a',
    '\u1EAD': 'a',
    '\u1EB7': 'a',
    '\u1E01': 'a',
    '\u0105': 'a',
    '\u2C65': 'a',
    '\u0250': 'a',
    '\uA733': 'aa',
    '\u00E6': 'ae',
    '\u01FD': 'ae',
    '\u01E3': 'ae',
    '\uA735': 'ao',
    '\uA737': 'au',
    '\uA739': 'av',
    '\uA73B': 'av',
    '\uA73D': 'ay',
    '\u24D1': 'b',
    '\uFF42': 'b',
    '\u1E03': 'b',
    '\u1E05': 'b',
    '\u1E07': 'b',
    '\u0180': 'b',
    '\u0183': 'b',
    '\u0253': 'b',
    '\u24D2': 'c',
    '\uFF43': 'c',
    '\u0107': 'c',
    '\u0109': 'c',
    '\u010B': 'c',
    '\u010D': 'c',
    '\u00E7': 'c',
    '\u1E09': 'c',
    '\u0188': 'c',
    '\u023C': 'c',
    '\uA73F': 'c',
    '\u2184': 'c',
    '\u24D3': 'd',
    '\uFF44': 'd',
    '\u1E0B': 'd',
    '\u010F': 'd',
    '\u1E0D': 'd',
    '\u1E11': 'd',
    '\u1E13': 'd',
    '\u1E0F': 'd',
    '\u0111': 'd',
    '\u018C': 'd',
    '\u0256': 'd',
    '\u0257': 'd',
    '\uA77A': 'd',
    '\u01F3': 'dz',
    '\u01C6': 'dz',
    '\u24D4': 'e',
    '\uFF45': 'e',
    '\u00E8': 'e',
    '\u00E9': 'e',
    '\u00EA': 'e',
    '\u1EC1': 'e',
    '\u1EBF': 'e',
    '\u1EC5': 'e',
    '\u1EC3': 'e',
    '\u1EBD': 'e',
    '\u0113': 'e',
    '\u1E15': 'e',
    '\u1E17': 'e',
    '\u0115': 'e',
    '\u0117': 'e',
    '\u00EB': 'e',
    '\u1EBB': 'e',
    '\u011B': 'e',
    '\u0205': 'e',
    '\u0207': 'e',
    '\u1EB9': 'e',
    '\u1EC7': 'e',
    '\u0229': 'e',
    '\u1E1D': 'e',
    '\u0119': 'e',
    '\u1E19': 'e',
    '\u1E1B': 'e',
    '\u0247': 'e',
    '\u025B': 'e',
    '\u01DD': 'e',
    '\u24D5': 'f',
    '\uFF46': 'f',
    '\u1E1F': 'f',
    '\u0192': 'f',
    '\uA77C': 'f',
    '\u24D6': 'g',
    '\uFF47': 'g',
    '\u01F5': 'g',
    '\u011D': 'g',
    '\u1E21': 'g',
    '\u011F': 'g',
    '\u0121': 'g',
    '\u01E7': 'g',
    '\u0123': 'g',
    '\u01E5': 'g',
    '\u0260': 'g',
    '\uA7A1': 'g',
    '\u1D79': 'g',
    '\uA77F': 'g',
    '\u24D7': 'h',
    '\uFF48': 'h',
    '\u0125': 'h',
    '\u1E23': 'h',
    '\u1E27': 'h',
    '\u021F': 'h',
    '\u1E25': 'h',
    '\u1E29': 'h',
    '\u1E2B': 'h',
    '\u1E96': 'h',
    '\u0127': 'h',
    '\u2C68': 'h',
    '\u2C76': 'h',
    '\u0265': 'h',
    '\u0195': 'hv',
    '\u24D8': 'i',
    '\uFF49': 'i',
    '\u00EC': 'i',
    '\u00ED': 'i',
    '\u00EE': 'i',
    '\u0129': 'i',
    '\u012B': 'i',
    '\u012D': 'i',
    '\u00EF': 'i',
    '\u1E2F': 'i',
    '\u1EC9': 'i',
    '\u01D0': 'i',
    '\u0209': 'i',
    '\u020B': 'i',
    '\u1ECB': 'i',
    '\u012F': 'i',
    '\u1E2D': 'i',
    '\u0268': 'i',
    '\u0131': 'i',
    '\u24D9': 'j',
    '\uFF4A': 'j',
    '\u0135': 'j',
    '\u01F0': 'j',
    '\u0249': 'j',
    '\u24DA': 'k',
    '\uFF4B': 'k',
    '\u1E31': 'k',
    '\u01E9': 'k',
    '\u1E33': 'k',
    '\u0137': 'k',
    '\u1E35': 'k',
    '\u0199': 'k',
    '\u2C6A': 'k',
    '\uA741': 'k',
    '\uA743': 'k',
    '\uA745': 'k',
    '\uA7A3': 'k',
    '\u24DB': 'l',
    '\uFF4C': 'l',
    '\u0140': 'l',
    '\u013A': 'l',
    '\u013E': 'l',
    '\u1E37': 'l',
    '\u1E39': 'l',
    '\u013C': 'l',
    '\u1E3D': 'l',
    '\u1E3B': 'l',
    '\u017F': 'l',
    '\u0142': 'l',
    '\u019A': 'l',
    '\u026B': 'l',
    '\u2C61': 'l',
    '\uA749': 'l',
    '\uA781': 'l',
    '\uA747': 'l',
    '\u01C9': 'lj',
    '\u24DC': 'm',
    '\uFF4D': 'm',
    '\u1E3F': 'm',
    '\u1E41': 'm',
    '\u1E43': 'm',
    '\u0271': 'm',
    '\u026F': 'm',
    '\u24DD': 'n',
    '\uFF4E': 'n',
    '\u01F9': 'n',
    '\u0144': 'n',
    '\u00F1': 'n',
    '\u1E45': 'n',
    '\u0148': 'n',
    '\u1E47': 'n',
    '\u0146': 'n',
    '\u1E4B': 'n',
    '\u1E49': 'n',
    '\u019E': 'n',
    '\u0272': 'n',
    '\u0149': 'n',
    '\uA791': 'n',
    '\uA7A5': 'n',
    '\u01CC': 'nj',
    '\u24DE': 'o',
    '\uFF4F': 'o',
    '\u00F2': 'o',
    '\u00F3': 'o',
    '\u00F4': 'o',
    '\u1ED3': 'o',
    '\u1ED1': 'o',
    '\u1ED7': 'o',
    '\u1ED5': 'o',
    '\u00F5': 'o',
    '\u1E4D': 'o',
    '\u022D': 'o',
    '\u1E4F': 'o',
    '\u014D': 'o',
    '\u1E51': 'o',
    '\u1E53': 'o',
    '\u014F': 'o',
    '\u022F': 'o',
    '\u0231': 'o',
    '\u00F6': 'o',
    '\u022B': 'o',
    '\u1ECF': 'o',
    '\u0151': 'o',
    '\u01D2': 'o',
    '\u020D': 'o',
    '\u020F': 'o',
    '\u01A1': 'o',
    '\u1EDD': 'o',
    '\u1EDB': 'o',
    '\u1EE1': 'o',
    '\u1EDF': 'o',
    '\u1EE3': 'o',
    '\u1ECD': 'o',
    '\u1ED9': 'o',
    '\u01EB': 'o',
    '\u01ED': 'o',
    '\u00F8': 'o',
    '\u01FF': 'o',
    '\u0254': 'o',
    '\uA74B': 'o',
    '\uA74D': 'o',
    '\u0275': 'o',
    '\u01A3': 'oi',
    '\u0223': 'ou',
    '\uA74F': 'oo',
    '\u24DF': 'p',
    '\uFF50': 'p',
    '\u1E55': 'p',
    '\u1E57': 'p',
    '\u01A5': 'p',
    '\u1D7D': 'p',
    '\uA751': 'p',
    '\uA753': 'p',
    '\uA755': 'p',
    '\u24E0': 'q',
    '\uFF51': 'q',
    '\u024B': 'q',
    '\uA757': 'q',
    '\uA759': 'q',
    '\u24E1': 'r',
    '\uFF52': 'r',
    '\u0155': 'r',
    '\u1E59': 'r',
    '\u0159': 'r',
    '\u0211': 'r',
    '\u0213': 'r',
    '\u1E5B': 'r',
    '\u1E5D': 'r',
    '\u0157': 'r',
    '\u1E5F': 'r',
    '\u024D': 'r',
    '\u027D': 'r',
    '\uA75B': 'r',
    '\uA7A7': 'r',
    '\uA783': 'r',
    '\u24E2': 's',
    '\uFF53': 's',
    '\u00DF': 's',
    '\u015B': 's',
    '\u1E65': 's',
    '\u015D': 's',
    '\u1E61': 's',
    '\u0161': 's',
    '\u1E67': 's',
    '\u1E63': 's',
    '\u1E69': 's',
    '\u0219': 's',
    '\u015F': 's',
    '\u023F': 's',
    '\uA7A9': 's',
    '\uA785': 's',
    '\u1E9B': 's',
    '\u24E3': 't',
    '\uFF54': 't',
    '\u1E6B': 't',
    '\u1E97': 't',
    '\u0165': 't',
    '\u1E6D': 't',
    '\u021B': 't',
    '\u0163': 't',
    '\u1E71': 't',
    '\u1E6F': 't',
    '\u0167': 't',
    '\u01AD': 't',
    '\u0288': 't',
    '\u2C66': 't',
    '\uA787': 't',
    '\uA729': 'tz',
    '\u24E4': 'u',
    '\uFF55': 'u',
    '\u00F9': 'u',
    '\u00FA': 'u',
    '\u00FB': 'u',
    '\u0169': 'u',
    '\u1E79': 'u',
    '\u016B': 'u',
    '\u1E7B': 'u',
    '\u016D': 'u',
    '\u00FC': 'u',
    '\u01DC': 'u',
    '\u01D8': 'u',
    '\u01D6': 'u',
    '\u01DA': 'u',
    '\u1EE7': 'u',
    '\u016F': 'u',
    '\u0171': 'u',
    '\u01D4': 'u',
    '\u0215': 'u',
    '\u0217': 'u',
    '\u01B0': 'u',
    '\u1EEB': 'u',
    '\u1EE9': 'u',
    '\u1EEF': 'u',
    '\u1EED': 'u',
    '\u1EF1': 'u',
    '\u1EE5': 'u',
    '\u1E73': 'u',
    '\u0173': 'u',
    '\u1E77': 'u',
    '\u1E75': 'u',
    '\u0289': 'u',
    '\u24E5': 'v',
    '\uFF56': 'v',
    '\u1E7D': 'v',
    '\u1E7F': 'v',
    '\u028B': 'v',
    '\uA75F': 'v',
    '\u028C': 'v',
    '\uA761': 'vy',
    '\u24E6': 'w',
    '\uFF57': 'w',
    '\u1E81': 'w',
    '\u1E83': 'w',
    '\u0175': 'w',
    '\u1E87': 'w',
    '\u1E85': 'w',
    '\u1E98': 'w',
    '\u1E89': 'w',
    '\u2C73': 'w',
    '\u24E7': 'x',
    '\uFF58': 'x',
    '\u1E8B': 'x',
    '\u1E8D': 'x',
    '\u24E8': 'y',
    '\uFF59': 'y',
    '\u1EF3': 'y',
    '\u00FD': 'y',
    '\u0177': 'y',
    '\u1EF9': 'y',
    '\u0233': 'y',
    '\u1E8F': 'y',
    '\u00FF': 'y',
    '\u1EF7': 'y',
    '\u1E99': 'y',
    '\u1EF5': 'y',
    '\u01B4': 'y',
    '\u024F': 'y',
    '\u1EFF': 'y',
    '\u24E9': 'z',
    '\uFF5A': 'z',
    '\u017A': 'z',
    '\u1E91': 'z',
    '\u017C': 'z',
    '\u017E': 'z',
    '\u1E93': 'z',
    '\u1E95': 'z',
    '\u01B6': 'z',
    '\u0225': 'z',
    '\u0240': 'z',
    '\u2C6C': 'z',
    '\uA763': 'z',
    '\u0386': '\u0391',
    '\u0388': '\u0395',
    '\u0389': '\u0397',
    '\u038A': '\u0399',
    '\u03AA': '\u0399',
    '\u038C': '\u039F',
    '\u038E': '\u03A5',
    '\u03AB': '\u03A5',
    '\u038F': '\u03A9',
    '\u03AC': '\u03B1',
    '\u03AD': '\u03B5',
    '\u03AE': '\u03B7',
    '\u03AF': '\u03B9',
    '\u03CA': '\u03B9',
    '\u0390': '\u03B9',
    '\u03CC': '\u03BF',
    '\u03CD': '\u03C5',
    '\u03CB': '\u03C5',
    '\u03B0': '\u03C5',
    '\u03C9': '\u03C9',
    '\u03C2': '\u03C3'
  };

  return diacritics;
});

S2.define('select2/data/base',[
  '../utils'
], function (Utils) {
  function BaseAdapter ($element, options) {
    BaseAdapter.__super__.constructor.call(this);
  }

  Utils.Extend(BaseAdapter, Utils.Observable);

  BaseAdapter.prototype.current = function (callback) {
    throw new Error('The `current` method must be defined in child classes.');
  };

  BaseAdapter.prototype.query = function (params, callback) {
    throw new Error('The `query` method must be defined in child classes.');
  };

  BaseAdapter.prototype.bind = function (container, $container) {
    // Can be implemented in subclasses
  };

  BaseAdapter.prototype.destroy = function () {
    // Can be implemented in subclasses
  };

  BaseAdapter.prototype.generateResultId = function (container, data) {
    var id = container.id + '-result-';

    id += Utils.generateChars(4);

    if (data.id != null) {
      id += '-' + data.id.toString();
    } else {
      id += '-' + Utils.generateChars(4);
    }
    return id;
  };

  return BaseAdapter;
});

S2.define('select2/data/select',[
  './base',
  '../utils',
  'jquery'
], function (BaseAdapter, Utils, $) {
  function SelectAdapter ($element, options) {
    this.$element = $element;
    this.options = options;

    SelectAdapter.__super__.constructor.call(this);
  }

  Utils.Extend(SelectAdapter, BaseAdapter);

  SelectAdapter.prototype.current = function (callback) {
    var data = [];
    var self = this;

    this.$element.find(':selected').each(function () {
      var $option = $(this);

      var option = self.item($option);

      data.push(option);
    });

    callback(data);
  };

  SelectAdapter.prototype.select = function (data) {
    var self = this;

    data.selected = true;

    // If data.element is a DOM node, use it instead
    if ($(data.element).is('option')) {
      data.element.selected = true;

      this.$element.trigger('change');

      return;
    }

    if (this.$element.prop('multiple')) {
      this.current(function (currentData) {
        var val = [];

        data = [data];
        data.push.apply(data, currentData);

        for (var d = 0; d < data.length; d++) {
          var id = data[d].id;

          if ($.inArray(id, val) === -1) {
            val.push(id);
          }
        }

        self.$element.val(val);
        self.$element.trigger('change');
      });
    } else {
      var val = data.id;

      this.$element.val(val);
      this.$element.trigger('change');
    }
  };

  SelectAdapter.prototype.unselect = function (data) {
    var self = this;

    if (!this.$element.prop('multiple')) {
      return;
    }

    data.selected = false;

    if ($(data.element).is('option')) {
      data.element.selected = false;

      this.$element.trigger('change');

      return;
    }

    this.current(function (currentData) {
      var val = [];

      for (var d = 0; d < currentData.length; d++) {
        var id = currentData[d].id;

        if (id !== data.id && $.inArray(id, val) === -1) {
          val.push(id);
        }
      }

      self.$element.val(val);

      self.$element.trigger('change');
    });
  };

  SelectAdapter.prototype.bind = function (container, $container) {
    var self = this;

    this.container = container;

    container.on('select', function (params) {
      self.select(params.data);
    });

    container.on('unselect', function (params) {
      self.unselect(params.data);
    });
  };

  SelectAdapter.prototype.destroy = function () {
    // Remove anything added to child elements
    this.$element.find('*').each(function () {
      // Remove any custom data set by Select2
      Utils.RemoveData(this);
    });
  };

  SelectAdapter.prototype.query = function (params, callback) {
    var data = [];
    var self = this;

    var $options = this.$element.children();

    $options.each(function () {
      var $option = $(this);

      if (!$option.is('option') && !$option.is('optgroup')) {
        return;
      }

      var option = self.item($option);

      var matches = self.matches(params, option);

      if (matches !== null) {
        data.push(matches);
      }
    });

    callback({
      results: data
    });
  };

  SelectAdapter.prototype.addOptions = function ($options) {
    Utils.appendMany(this.$element, $options);
  };

  SelectAdapter.prototype.option = function (data) {
    var option;

    if (data.children) {
      option = document.createElement('optgroup');
      option.label = data.text;
    } else {
      option = document.createElement('option');

      if (option.textContent !== undefined) {
        option.textContent = data.text;
      } else {
        option.innerText = data.text;
      }
    }

    if (data.id !== undefined) {
      option.value = data.id;
    }

    if (data.disabled) {
      option.disabled = true;
    }

    if (data.selected) {
      option.selected = true;
    }

    if (data.title) {
      option.title = data.title;
    }

    var $option = $(option);

    var normalizedData = this._normalizeItem(data);
    normalizedData.element = option;

    // Override the option's data with the combined data
    Utils.StoreData(option, 'data', normalizedData);

    return $option;
  };

  SelectAdapter.prototype.item = function ($option) {
    var data = {};

    data = Utils.GetData($option[0], 'data');

    if (data != null) {
      return data;
    }

    if ($option.is('option')) {
      data = {
        id: $option.val(),
        text: $option.text(),
        disabled: $option.prop('disabled'),
        selected: $option.prop('selected'),
        title: $option.prop('title')
      };
    } else if ($option.is('optgroup')) {
      data = {
        text: $option.prop('label'),
        children: [],
        title: $option.prop('title')
      };

      var $children = $option.children('option');
      var children = [];

      for (var c = 0; c < $children.length; c++) {
        var $child = $($children[c]);

        var child = this.item($child);

        children.push(child);
      }

      data.children = children;
    }

    data = this._normalizeItem(data);
    data.element = $option[0];

    Utils.StoreData($option[0], 'data', data);

    return data;
  };

  SelectAdapter.prototype._normalizeItem = function (item) {
    if (item !== Object(item)) {
      item = {
        id: item,
        text: item
      };
    }

    item = $.extend({}, {
      text: ''
    }, item);

    var defaults = {
      selected: false,
      disabled: false
    };

    if (item.id != null) {
      item.id = item.id.toString();
    }

    if (item.text != null) {
      item.text = item.text.toString();
    }

    if (item._resultId == null && item.id && this.container != null) {
      item._resultId = this.generateResultId(this.container, item);
    }

    return $.extend({}, defaults, item);
  };

  SelectAdapter.prototype.matches = function (params, data) {
    var matcher = this.options.get('matcher');

    return matcher(params, data);
  };

  return SelectAdapter;
});

S2.define('select2/data/array',[
  './select',
  '../utils',
  'jquery'
], function (SelectAdapter, Utils, $) {
  function ArrayAdapter ($element, options) {
    var data = options.get('data') || [];

    ArrayAdapter.__super__.constructor.call(this, $element, options);

    this.addOptions(this.convertToOptions(data));
  }

  Utils.Extend(ArrayAdapter, SelectAdapter);

  ArrayAdapter.prototype.select = function (data) {
    var $option = this.$element.find('option').filter(function (i, elm) {
      return elm.value == data.id.toString();
    });

    if ($option.length === 0) {
      $option = this.option(data);

      this.addOptions($option);
    }

    ArrayAdapter.__super__.select.call(this, data);
  };

  ArrayAdapter.prototype.convertToOptions = function (data) {
    var self = this;

    var $existing = this.$element.find('option');
    var existingIds = $existing.map(function () {
      return self.item($(this)).id;
    }).get();

    var $options = [];

    // Filter out all items except for the one passed in the argument
    function onlyItem (item) {
      return function () {
        return $(this).val() == item.id;
      };
    }

    for (var d = 0; d < data.length; d++) {
      var item = this._normalizeItem(data[d]);

      // Skip items which were pre-loaded, only merge the data
      if ($.inArray(item.id, existingIds) >= 0) {
        var $existingOption = $existing.filter(onlyItem(item));

        var existingData = this.item($existingOption);
        var newData = $.extend(true, {}, item, existingData);

        var $newOption = this.option(newData);

        $existingOption.replaceWith($newOption);

        continue;
      }

      var $option = this.option(item);

      if (item.children) {
        var $children = this.convertToOptions(item.children);

        Utils.appendMany($option, $children);
      }

      $options.push($option);
    }

    return $options;
  };

  return ArrayAdapter;
});

S2.define('select2/data/ajax',[
  './array',
  '../utils',
  'jquery'
], function (ArrayAdapter, Utils, $) {
  function AjaxAdapter ($element, options) {
    this.ajaxOptions = this._applyDefaults(options.get('ajax'));

    if (this.ajaxOptions.processResults != null) {
      this.processResults = this.ajaxOptions.processResults;
    }

    AjaxAdapter.__super__.constructor.call(this, $element, options);
  }

  Utils.Extend(AjaxAdapter, ArrayAdapter);

  AjaxAdapter.prototype._applyDefaults = function (options) {
    var defaults = {
      data: function (params) {
        return $.extend({}, params, {
          q: params.term
        });
      },
      transport: function (params, success, failure) {
        var $request = $.ajax(params);

        $request.then(success);
        $request.fail(failure);

        return $request;
      }
    };

    return $.extend({}, defaults, options, true);
  };

  AjaxAdapter.prototype.processResults = function (results) {
    return results;
  };

  AjaxAdapter.prototype.query = function (params, callback) {
    var matches = [];
    var self = this;

    if (this._request != null) {
      // JSONP requests cannot always be aborted
      if ($.isFunction(this._request.abort)) {
        this._request.abort();
      }

      this._request = null;
    }

    var options = $.extend({
      type: 'GET'
    }, this.ajaxOptions);

    if (typeof options.url === 'function') {
      options.url = options.url.call(this.$element, params);
    }

    if (typeof options.data === 'function') {
      options.data = options.data.call(this.$element, params);
    }

    function request () {
      var $request = options.transport(options, function (data) {
        var results = self.processResults(data, params);

        if (self.options.get('debug') && window.console && console.error) {
          // Check to make sure that the response included a `results` key.
          if (!results || !results.results || !$.isArray(results.results)) {
            console.error(
              'Select2: The AJAX results did not return an array in the ' +
              '`results` key of the response.'
            );
          }
        }

        callback(results);
      }, function () {
        // Attempt to detect if a request was aborted
        // Only works if the transport exposes a status property
        if ('status' in $request &&
            ($request.status === 0 || $request.status === '0')) {
          return;
        }

        self.trigger('results:message', {
          message: 'errorLoading'
        });
      });

      self._request = $request;
    }

    if (this.ajaxOptions.delay && params.term != null) {
      if (this._queryTimeout) {
        window.clearTimeout(this._queryTimeout);
      }

      this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
    } else {
      request();
    }
  };

  return AjaxAdapter;
});

S2.define('select2/data/tags',[
  'jquery'
], function ($) {
  function Tags (decorated, $element, options) {
    var tags = options.get('tags');

    var createTag = options.get('createTag');

    if (createTag !== undefined) {
      this.createTag = createTag;
    }

    var insertTag = options.get('insertTag');

    if (insertTag !== undefined) {
        this.insertTag = insertTag;
    }

    decorated.call(this, $element, options);

    if ($.isArray(tags)) {
      for (var t = 0; t < tags.length; t++) {
        var tag = tags[t];
        var item = this._normalizeItem(tag);

        var $option = this.option(item);

        this.$element.append($option);
      }
    }
  }

  Tags.prototype.query = function (decorated, params, callback) {
    var self = this;

    this._removeOldTags();

    if (params.term == null || params.page != null) {
      decorated.call(this, params, callback);
      return;
    }

    function wrapper (obj, child) {
      var data = obj.results;

      for (var i = 0; i < data.length; i++) {
        var option = data[i];

        var checkChildren = (
          option.children != null &&
          !wrapper({
            results: option.children
          }, true)
        );

        var optionText = (option.text || '').toUpperCase();
        var paramsTerm = (params.term || '').toUpperCase();

        var checkText = optionText === paramsTerm;

        if (checkText || checkChildren) {
          if (child) {
            return false;
          }

          obj.data = data;
          callback(obj);

          return;
        }
      }

      if (child) {
        return true;
      }

      var tag = self.createTag(params);

      if (tag != null) {
        var $option = self.option(tag);
        $option.attr('data-select2-tag', true);

        self.addOptions([$option]);

        self.insertTag(data, tag);
      }

      obj.results = data;

      callback(obj);
    }

    decorated.call(this, params, wrapper);
  };

  Tags.prototype.createTag = function (decorated, params) {
    var term = $.trim(params.term);

    if (term === '') {
      return null;
    }

    return {
      id: term,
      text: term
    };
  };

  Tags.prototype.insertTag = function (_, data, tag) {
    data.unshift(tag);
  };

  Tags.prototype._removeOldTags = function (_) {
    var tag = this._lastTag;

    var $options = this.$element.find('option[data-select2-tag]');

    $options.each(function () {
      if (this.selected) {
        return;
      }

      $(this).remove();
    });
  };

  return Tags;
});

S2.define('select2/data/tokenizer',[
  'jquery'
], function ($) {
  function Tokenizer (decorated, $element, options) {
    var tokenizer = options.get('tokenizer');

    if (tokenizer !== undefined) {
      this.tokenizer = tokenizer;
    }

    decorated.call(this, $element, options);
  }

  Tokenizer.prototype.bind = function (decorated, container, $container) {
    decorated.call(this, container, $container);

    this.$search =  container.dropdown.$search || container.selection.$search ||
      $container.find('.select2-search__field');
  };

  Tokenizer.prototype.query = function (decorated, params, callback) {
    var self = this;

    function createAndSelect (data) {
      // Normalize the data object so we can use it for checks
      var item = self._normalizeItem(data);

      // Check if the data object already exists as a tag
      // Select it if it doesn't
      var $existingOptions = self.$element.find('option').filter(function () {
        return $(this).val() === item.id;
      });

      // If an existing option wasn't found for it, create the option
      if (!$existingOptions.length) {
        var $option = self.option(item);
        $option.attr('data-select2-tag', true);

        self._removeOldTags();
        self.addOptions([$option]);
      }

      // Select the item, now that we know there is an option for it
      select(item);
    }

    function select (data) {
      self.trigger('select', {
        data: data
      });
    }

    params.term = params.term || '';

    var tokenData = this.tokenizer(params, this.options, createAndSelect);

    if (tokenData.term !== params.term) {
      // Replace the search term if we have the search box
      if (this.$search.length) {
        this.$search.val(tokenData.term);
        this.$search.focus();
      }

      params.term = tokenData.term;
    }

    decorated.call(this, params, callback);
  };

  Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
    var separators = options.get('tokenSeparators') || [];
    var term = params.term;
    var i = 0;

    var createTag = this.createTag || function (params) {
      return {
        id: params.term,
        text: params.term
      };
    };

    while (i < term.length) {
      var termChar = term[i];

      if ($.inArray(termChar, separators) === -1) {
        i++;

        continue;
      }

      var part = term.substr(0, i);
      var partParams = $.extend({}, params, {
        term: part
      });

      var data = createTag(partParams);

      if (data == null) {
        i++;
        continue;
      }

      callback(data);

      // Reset the term to not include the tokenized portion
      term = term.substr(i + 1) || '';
      i = 0;
    }

    return {
      term: term
    };
  };

  return Tokenizer;
});

S2.define('select2/data/minimumInputLength',[

], function () {
  function MinimumInputLength (decorated, $e, options) {
    this.minimumInputLength = options.get('minimumInputLength');

    decorated.call(this, $e, options);
  }

  MinimumInputLength.prototype.query = function (decorated, params, callback) {
    params.term = params.term || '';

    if (params.term.length < this.minimumInputLength) {
      this.trigger('results:message', {
        message: 'inputTooShort',
        args: {
          minimum: this.minimumInputLength,
          input: params.term,
          params: params
        }
      });

      return;
    }

    decorated.call(this, params, callback);
  };

  return MinimumInputLength;
});

S2.define('select2/data/maximumInputLength',[

], function () {
  function MaximumInputLength (decorated, $e, options) {
    this.maximumInputLength = options.get('maximumInputLength');

    decorated.call(this, $e, options);
  }

  MaximumInputLength.prototype.query = function (decorated, params, callback) {
    params.term = params.term || '';

    if (this.maximumInputLength > 0 &&
        params.term.length > this.maximumInputLength) {
      this.trigger('results:message', {
        message: 'inputTooLong',
        args: {
          maximum: this.maximumInputLength,
          input: params.term,
          params: params
        }
      });

      return;
    }

    decorated.call(this, params, callback);
  };

  return MaximumInputLength;
});

S2.define('select2/data/maximumSelectionLength',[

], function (){
  function MaximumSelectionLength (decorated, $e, options) {
    this.maximumSelectionLength = options.get('maximumSelectionLength');

    decorated.call(this, $e, options);
  }

  MaximumSelectionLength.prototype.query =
    function (decorated, params, callback) {
      var self = this;

      this.current(function (currentData) {
        var count = currentData != null ? currentData.length : 0;
        if (self.maximumSelectionLength > 0 &&
          count >= self.maximumSelectionLength) {
          self.trigger('results:message', {
            message: 'maximumSelected',
            args: {
              maximum: self.maximumSelectionLength
            }
          });
          return;
        }
        decorated.call(self, params, callback);
      });
  };

  return MaximumSelectionLength;
});

S2.define('select2/dropdown',[
  'jquery',
  './utils'
], function ($, Utils) {
  function Dropdown ($element, options) {
    this.$element = $element;
    this.options = options;

    Dropdown.__super__.constructor.call(this);
  }

  Utils.Extend(Dropdown, Utils.Observable);

  Dropdown.prototype.render = function () {
    var $dropdown = $(
      '<span class="select2-dropdown">' +
        '<span class="select2-results"></span>' +
      '</span>'
    );

    $dropdown.attr('dir', this.options.get('dir'));

    this.$dropdown = $dropdown;

    return $dropdown;
  };

  Dropdown.prototype.bind = function () {
    // Should be implemented in subclasses
  };

  Dropdown.prototype.position = function ($dropdown, $container) {
    // Should be implmented in subclasses
  };

  Dropdown.prototype.destroy = function () {
    // Remove the dropdown from the DOM
    this.$dropdown.remove();
  };

  return Dropdown;
});

S2.define('select2/dropdown/search',[
  'jquery',
  '../utils'
], function ($, Utils) {
  function Search () { }

  Search.prototype.render = function (decorated) {
    var $rendered = decorated.call(this);

    var $search = $(
      '<span class="select2-search select2-search--dropdown">' +
        '<input class="select2-search__field" type="search" tabindex="-1"' +
        ' autocomplete="off" autocorrect="off" autocapitalize="none"' +
        ' spellcheck="false" role="textbox" />' +
      '</span>'
    );

    this.$searchContainer = $search;
    this.$search = $search.find('input');

    $rendered.prepend($search);

    return $rendered;
  };

  Search.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    this.$search.on('keydown', function (evt) {
      self.trigger('keypress', evt);

      self._keyUpPrevented = evt.isDefaultPrevented();
    });

    // Workaround for browsers which do not support the `input` event
    // This will prevent double-triggering of events for browsers which support
    // both the `keyup` and `input` events.
    this.$search.on('input', function (evt) {
      // Unbind the duplicated `keyup` event
      $(this).off('keyup');
    });

    this.$search.on('keyup input', function (evt) {
      self.handleSearch(evt);
    });

    container.on('open', function () {
      self.$search.attr('tabindex', 0);

      self.$search.focus();

      window.setTimeout(function () {
        self.$search.focus();
      }, 0);
    });

    container.on('close', function () {
      self.$search.attr('tabindex', -1);

      self.$search.val('');
      self.$search.blur();
    });

    container.on('focus', function () {
      if (!container.isOpen()) {
        self.$search.focus();
      }
    });

    container.on('results:all', function (params) {
      if (params.query.term == null || params.query.term === '') {
        var showSearch = self.showSearch(params);

        if (showSearch) {
          self.$searchContainer.removeClass('select2-search--hide');
        } else {
          self.$searchContainer.addClass('select2-search--hide');
        }
      }
    });
  };

  Search.prototype.handleSearch = function (evt) {
    if (!this._keyUpPrevented) {
      var input = this.$search.val();

      this.trigger('query', {
        term: input
      });
    }

    this._keyUpPrevented = false;
  };

  Search.prototype.showSearch = function (_, params) {
    return true;
  };

  return Search;
});

S2.define('select2/dropdown/hidePlaceholder',[

], function () {
  function HidePlaceholder (decorated, $element, options, dataAdapter) {
    this.placeholder = this.normalizePlaceholder(options.get('placeholder'));

    decorated.call(this, $element, options, dataAdapter);
  }

  HidePlaceholder.prototype.append = function (decorated, data) {
    data.results = this.removePlaceholder(data.results);

    decorated.call(this, data);
  };

  HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
    if (typeof placeholder === 'string') {
      placeholder = {
        id: '',
        text: placeholder
      };
    }

    return placeholder;
  };

  HidePlaceholder.prototype.removePlaceholder = function (_, data) {
    var modifiedData = data.slice(0);

    for (var d = data.length - 1; d >= 0; d--) {
      var item = data[d];

      if (this.placeholder.id === item.id) {
        modifiedData.splice(d, 1);
      }
    }

    return modifiedData;
  };

  return HidePlaceholder;
});

S2.define('select2/dropdown/infiniteScroll',[
  'jquery'
], function ($) {
  function InfiniteScroll (decorated, $element, options, dataAdapter) {
    this.lastParams = {};

    decorated.call(this, $element, options, dataAdapter);

    this.$loadingMore = this.createLoadingMore();
    this.loading = false;
  }

  InfiniteScroll.prototype.append = function (decorated, data) {
    this.$loadingMore.remove();
    this.loading = false;

    decorated.call(this, data);

    if (this.showLoadingMore(data)) {
      this.$results.append(this.$loadingMore);
    }
  };

  InfiniteScroll.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    container.on('query', function (params) {
      self.lastParams = params;
      self.loading = true;
    });

    container.on('query:append', function (params) {
      self.lastParams = params;
      self.loading = true;
    });

    this.$results.on('scroll', function () {
      var isLoadMoreVisible = $.contains(
        document.documentElement,
        self.$loadingMore[0]
      );

      if (self.loading || !isLoadMoreVisible) {
        return;
      }

      var currentOffset = self.$results.offset().top +
        self.$results.outerHeight(false);
      var loadingMoreOffset = self.$loadingMore.offset().top +
        self.$loadingMore.outerHeight(false);

      if (currentOffset + 50 >= loadingMoreOffset) {
        self.loadMore();
      }
    });
  };

  InfiniteScroll.prototype.loadMore = function () {
    this.loading = true;

    var params = $.extend({}, {page: 1}, this.lastParams);

    params.page++;

    this.trigger('query:append', params);
  };

  InfiniteScroll.prototype.showLoadingMore = function (_, data) {
    return data.pagination && data.pagination.more;
  };

  InfiniteScroll.prototype.createLoadingMore = function () {
    var $option = $(
      '<li ' +
      'class="select2-results__option select2-results__option--load-more"' +
      'role="treeitem" aria-disabled="true"></li>'
    );

    var message = this.options.get('translations').get('loadingMore');

    $option.html(message(this.lastParams));

    return $option;
  };

  return InfiniteScroll;
});

S2.define('select2/dropdown/attachBody',[
  'jquery',
  '../utils'
], function ($, Utils) {
  function AttachBody (decorated, $element, options) {
    this.$dropdownParent = options.get('dropdownParent') || $(document.body);

    decorated.call(this, $element, options);
  }

  AttachBody.prototype.bind = function (decorated, container, $container) {
    var self = this;

    var setupResultsEvents = false;

    decorated.call(this, container, $container);

    container.on('open', function () {
      self._showDropdown();
      self._attachPositioningHandler(container);

      if (!setupResultsEvents) {
        setupResultsEvents = true;

        container.on('results:all', function () {
          self._positionDropdown();
          self._resizeDropdown();
        });

        container.on('results:append', function () {
          self._positionDropdown();
          self._resizeDropdown();
        });
      }
    });

    container.on('close', function () {
      self._hideDropdown();
      self._detachPositioningHandler(container);
    });

    this.$dropdownContainer.on('mousedown', function (evt) {
      evt.stopPropagation();
    });
  };

  AttachBody.prototype.destroy = function (decorated) {
    decorated.call(this);

    this.$dropdownContainer.remove();
  };

  AttachBody.prototype.position = function (decorated, $dropdown, $container) {
    // Clone all of the container classes
    $dropdown.attr('class', $container.attr('class'));

    $dropdown.removeClass('select2');
    $dropdown.addClass('select2-container--open');

    $dropdown.css({
      position: 'absolute',
      top: -999999
    });

    this.$container = $container;
  };

  AttachBody.prototype.render = function (decorated) {
    var $container = $('<span></span>');

    var $dropdown = decorated.call(this);
    $container.append($dropdown);

    this.$dropdownContainer = $container;

    return $container;
  };

  AttachBody.prototype._hideDropdown = function (decorated) {
    this.$dropdownContainer.detach();
  };

  AttachBody.prototype._attachPositioningHandler =
      function (decorated, container) {
    var self = this;

    var scrollEvent = 'scroll.select2.' + container.id;
    var resizeEvent = 'resize.select2.' + container.id;
    var orientationEvent = 'orientationchange.select2.' + container.id;

    var $watchers = this.$container.parents().filter(Utils.hasScroll);
    $watchers.each(function () {
      Utils.StoreData(this, 'select2-scroll-position', {
        x: $(this).scrollLeft(),
        y: $(this).scrollTop()
      });
    });

    $watchers.on(scrollEvent, function (ev) {
      var position = Utils.GetData(this, 'select2-scroll-position');
      $(this).scrollTop(position.y);
    });

    $(window).on(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent,
      function (e) {
      self._positionDropdown();
      self._resizeDropdown();
    });
  };

  AttachBody.prototype._detachPositioningHandler =
      function (decorated, container) {
    var scrollEvent = 'scroll.select2.' + container.id;
    var resizeEvent = 'resize.select2.' + container.id;
    var orientationEvent = 'orientationchange.select2.' + container.id;

    var $watchers = this.$container.parents().filter(Utils.hasScroll);
    $watchers.off(scrollEvent);

    $(window).off(scrollEvent + ' ' + resizeEvent + ' ' + orientationEvent);
  };

  AttachBody.prototype._positionDropdown = function () {
    var $window = $(window);

    var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
    var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');

    var newDirection = null;

    var offset = this.$container.offset();

    offset.bottom = offset.top + this.$container.outerHeight(false);

    var container = {
      height: this.$container.outerHeight(false)
    };

    container.top = offset.top;
    container.bottom = offset.top + container.height;

    var dropdown = {
      height: this.$dropdown.outerHeight(false)
    };

    var viewport = {
      top: $window.scrollTop(),
      bottom: $window.scrollTop() + $window.height()
    };

    var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
    var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);

    var css = {
      left: offset.left,
      top: container.bottom
    };

    // Determine what the parent element is to use for calciulating the offset
    var $offsetParent = this.$dropdownParent;

    // For statically positoned elements, we need to get the element
    // that is determining the offset
    if ($offsetParent.css('position') === 'static') {
      $offsetParent = $offsetParent.offsetParent();
    }

    var parentOffset = $offsetParent.offset();

    css.top -= parentOffset.top;
    css.left -= parentOffset.left;

    if (!isCurrentlyAbove && !isCurrentlyBelow) {
      newDirection = 'below';
    }

    if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
      newDirection = 'above';
    } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
      newDirection = 'below';
    }

    if (newDirection == 'above' ||
      (isCurrentlyAbove && newDirection !== 'below')) {
      css.top = container.top - parentOffset.top - dropdown.height;
    }

    if (newDirection != null) {
      this.$dropdown
        .removeClass('select2-dropdown--below select2-dropdown--above')
        .addClass('select2-dropdown--' + newDirection);
      this.$container
        .removeClass('select2-container--below select2-container--above')
        .addClass('select2-container--' + newDirection);
    }

    this.$dropdownContainer.css(css);
  };

  AttachBody.prototype._resizeDropdown = function () {
    var css = {
      width: this.$container.outerWidth(false) + 'px'
    };

    if (this.options.get('dropdownAutoWidth')) {
      css.minWidth = css.width;
      css.position = 'relative';
      css.width = 'auto';
    }

    this.$dropdown.css(css);
  };

  AttachBody.prototype._showDropdown = function (decorated) {
    this.$dropdownContainer.appendTo(this.$dropdownParent);

    this._positionDropdown();
    this._resizeDropdown();
  };

  return AttachBody;
});

S2.define('select2/dropdown/minimumResultsForSearch',[

], function () {
  function countResults (data) {
    var count = 0;

    for (var d = 0; d < data.length; d++) {
      var item = data[d];

      if (item.children) {
        count += countResults(item.children);
      } else {
        count++;
      }
    }

    return count;
  }

  function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
    this.minimumResultsForSearch = options.get('minimumResultsForSearch');

    if (this.minimumResultsForSearch < 0) {
      this.minimumResultsForSearch = Infinity;
    }

    decorated.call(this, $element, options, dataAdapter);
  }

  MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
    if (countResults(params.data.results) < this.minimumResultsForSearch) {
      return false;
    }

    return decorated.call(this, params);
  };

  return MinimumResultsForSearch;
});

S2.define('select2/dropdown/selectOnClose',[
  '../utils'
], function (Utils) {
  function SelectOnClose () { }

  SelectOnClose.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    container.on('close', function (params) {
      self._handleSelectOnClose(params);
    });
  };

  SelectOnClose.prototype._handleSelectOnClose = function (_, params) {
    if (params && params.originalSelect2Event != null) {
      var event = params.originalSelect2Event;

      // Don't select an item if the close event was triggered from a select or
      // unselect event
      if (event._type === 'select' || event._type === 'unselect') {
        return;
      }
    }

    var $highlightedResults = this.getHighlightedResults();

    // Only select highlighted results
    if ($highlightedResults.length < 1) {
      return;
    }

    var data = Utils.GetData($highlightedResults[0], 'data');

    // Don't re-select already selected resulte
    if (
      (data.element != null && data.element.selected) ||
      (data.element == null && data.selected)
    ) {
      return;
    }

    this.trigger('select', {
        data: data
    });
  };

  return SelectOnClose;
});

S2.define('select2/dropdown/closeOnSelect',[

], function () {
  function CloseOnSelect () { }

  CloseOnSelect.prototype.bind = function (decorated, container, $container) {
    var self = this;

    decorated.call(this, container, $container);

    container.on('select', function (evt) {
      self._selectTriggered(evt);
    });

    container.on('unselect', function (evt) {
      self._selectTriggered(evt);
    });
  };

  CloseOnSelect.prototype._selectTriggered = function (_, evt) {
    var originalEvent = evt.originalEvent;

    // Don't close if the control key is being held
    if (originalEvent && originalEvent.ctrlKey) {
      return;
    }

    this.trigger('close', {
      originalEvent: originalEvent,
      originalSelect2Event: evt
    });
  };

  return CloseOnSelect;
});

S2.define('select2/i18n/en',[],function () {
  // English
  return {
    errorLoading: function () {
      return 'The results could not be loaded.';
    },
    inputTooLong: function (args) {
      var overChars = args.input.length - args.maximum;

      var message = 'Please delete ' + overChars + ' character';

      if (overChars != 1) {
        message += 's';
      }

      return message;
    },
    inputTooShort: function (args) {
      var remainingChars = args.minimum - args.input.length;

      var message = 'Please enter ' + remainingChars + ' or more characters';

      return message;
    },
    loadingMore: function () {
      return 'Loading more results…';
    },
    maximumSelected: function (args) {
      var message = 'You can only select ' + args.maximum + ' item';

      if (args.maximum != 1) {
        message += 's';
      }

      return message;
    },
    noResults: function () {
      return 'No results found';
    },
    searching: function () {
      return 'Searching…';
    }
  };
});

S2.define('select2/defaults',[
  'jquery',
  'require',

  './results',

  './selection/single',
  './selection/multiple',
  './selection/placeholder',
  './selection/allowClear',
  './selection/search',
  './selection/eventRelay',

  './utils',
  './translation',
  './diacritics',

  './data/select',
  './data/array',
  './data/ajax',
  './data/tags',
  './data/tokenizer',
  './data/minimumInputLength',
  './data/maximumInputLength',
  './data/maximumSelectionLength',

  './dropdown',
  './dropdown/search',
  './dropdown/hidePlaceholder',
  './dropdown/infiniteScroll',
  './dropdown/attachBody',
  './dropdown/minimumResultsForSearch',
  './dropdown/selectOnClose',
  './dropdown/closeOnSelect',

  './i18n/en'
], function ($, require,

             ResultsList,

             SingleSelection, MultipleSelection, Placeholder, AllowClear,
             SelectionSearch, EventRelay,

             Utils, Translation, DIACRITICS,

             SelectData, ArrayData, AjaxData, Tags, Tokenizer,
             MinimumInputLength, MaximumInputLength, MaximumSelectionLength,

             Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
             AttachBody, MinimumResultsForSearch, SelectOnClose, CloseOnSelect,

             EnglishTranslation) {
  function Defaults () {
    this.reset();
  }

  Defaults.prototype.apply = function (options) {
    options = $.extend(true, {}, this.defaults, options);

    if (options.dataAdapter == null) {
      if (options.ajax != null) {
        options.dataAdapter = AjaxData;
      } else if (options.data != null) {
        options.dataAdapter = ArrayData;
      } else {
        options.dataAdapter = SelectData;
      }

      if (options.minimumInputLength > 0) {
        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          MinimumInputLength
        );
      }

      if (options.maximumInputLength > 0) {
        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          MaximumInputLength
        );
      }

      if (options.maximumSelectionLength > 0) {
        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          MaximumSelectionLength
        );
      }

      if (options.tags) {
        options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
      }

      if (options.tokenSeparators != null || options.tokenizer != null) {
        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          Tokenizer
        );
      }

      if (options.query != null) {
        var Query = require(options.amdBase + 'compat/query');

        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          Query
        );
      }

      if (options.initSelection != null) {
        var InitSelection = require(options.amdBase + 'compat/initSelection');

        options.dataAdapter = Utils.Decorate(
          options.dataAdapter,
          InitSelection
        );
      }
    }

    if (options.resultsAdapter == null) {
      options.resultsAdapter = ResultsList;

      if (options.ajax != null) {
        options.resultsAdapter = Utils.Decorate(
          options.resultsAdapter,
          InfiniteScroll
        );
      }

      if (options.placeholder != null) {
        options.resultsAdapter = Utils.Decorate(
          options.resultsAdapter,
          HidePlaceholder
        );
      }

      if (options.selectOnClose) {
        options.resultsAdapter = Utils.Decorate(
          options.resultsAdapter,
          SelectOnClose
        );
      }
    }

    if (options.dropdownAdapter == null) {
      if (options.multiple) {
        options.dropdownAdapter = Dropdown;
      } else {
        var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);

        options.dropdownAdapter = SearchableDropdown;
      }

      if (options.minimumResultsForSearch !== 0) {
        options.dropdownAdapter = Utils.Decorate(
          options.dropdownAdapter,
          MinimumResultsForSearch
        );
      }

      if (options.closeOnSelect) {
        options.dropdownAdapter = Utils.Decorate(
          options.dropdownAdapter,
          CloseOnSelect
        );
      }

      if (
        options.dropdownCssClass != null ||
        options.dropdownCss != null ||
        options.adaptDropdownCssClass != null
      ) {
        var DropdownCSS = require(options.amdBase + 'compat/dropdownCss');

        options.dropdownAdapter = Utils.Decorate(
          options.dropdownAdapter,
          DropdownCSS
        );
      }

      options.dropdownAdapter = Utils.Decorate(
        options.dropdownAdapter,
        AttachBody
      );
    }

    if (options.selectionAdapter == null) {
      if (options.multiple) {
        options.selectionAdapter = MultipleSelection;
      } else {
        options.selectionAdapter = SingleSelection;
      }

      // Add the placeholder mixin if a placeholder was specified
      if (options.placeholder != null) {
        options.selectionAdapter = Utils.Decorate(
          options.selectionAdapter,
          Placeholder
        );
      }

      if (options.allowClear) {
        options.selectionAdapter = Utils.Decorate(
          options.selectionAdapter,
          AllowClear
        );
      }

      if (options.multiple) {
        options.selectionAdapter = Utils.Decorate(
          options.selectionAdapter,
          SelectionSearch
        );
      }

      if (
        options.containerCssClass != null ||
        options.containerCss != null ||
        options.adaptContainerCssClass != null
      ) {
        var ContainerCSS = require(options.amdBase + 'compat/containerCss');

        options.selectionAdapter = Utils.Decorate(
          options.selectionAdapter,
          ContainerCSS
        );
      }

      options.selectionAdapter = Utils.Decorate(
        options.selectionAdapter,
        EventRelay
      );
    }

    if (typeof options.language === 'string') {
      // Check if the language is specified with a region
      if (options.language.indexOf('-') > 0) {
        // Extract the region information if it is included
        var languageParts = options.language.split('-');
        var baseLanguage = languageParts[0];

        options.language = [options.language, baseLanguage];
      } else {
        options.language = [options.language];
      }
    }

    if ($.isArray(options.language)) {
      var languages = new Translation();
      options.language.push('en');

      var languageNames = options.language;

      for (var l = 0; l < languageNames.length; l++) {
        var name = languageNames[l];
        var language = {};

        try {
          // Try to load it with the original name
          language = Translation.loadPath(name);
        } catch (e) {
          try {
            // If we couldn't load it, check if it wasn't the full path
            name = this.defaults.amdLanguageBase + name;
            language = Translation.loadPath(name);
          } catch (ex) {
            // The translation could not be loaded at all. Sometimes this is
            // because of a configuration problem, other times this can be
            // because of how Select2 helps load all possible translation files.
            if (options.debug && window.console && console.warn) {
              console.warn(
                'Select2: The language file for "' + name + '" could not be ' +
                'automatically loaded. A fallback will be used instead.'
              );
            }

            continue;
          }
        }

        languages.extend(language);
      }

      options.translations = languages;
    } else {
      var baseTranslation = Translation.loadPath(
        this.defaults.amdLanguageBase + 'en'
      );
      var customTranslation = new Translation(options.language);

      customTranslation.extend(baseTranslation);

      options.translations = customTranslation;
    }

    return options;
  };

  Defaults.prototype.reset = function () {
    function stripDiacritics (text) {
      // Used 'uni range + named function' from http://jsperf.com/diacritics/18
      function match(a) {
        return DIACRITICS[a] || a;
      }

      return text.replace(/[^\u0000-\u007E]/g, match);
    }

    function matcher (params, data) {
      // Always return the object if there is nothing to compare
      if ($.trim(params.term) === '') {
        return data;
      }

      // Do a recursive check for options with children
      if (data.children && data.children.length > 0) {
        // Clone the data object if there are children
        // This is required as we modify the object to remove any non-matches
        var match = $.extend(true, {}, data);

        // Check each child of the option
        for (var c = data.children.length - 1; c >= 0; c--) {
          var child = data.children[c];

          var matches = matcher(params, child);

          // If there wasn't a match, remove the object in the array
          if (matches == null) {
            match.children.splice(c, 1);
          }
        }

        // If any children matched, return the new object
        if (match.children.length > 0) {
          return match;
        }

        // If there were no matching children, check just the plain object
        return matcher(params, match);
      }

      var original = stripDiacritics(data.text).toUpperCase();
      var term = stripDiacritics(params.term).toUpperCase();

      // Check if the text contains the term
      if (original.indexOf(term) > -1) {
        return data;
      }

      // If it doesn't contain the term, don't return anything
      return null;
    }

    this.defaults = {
      amdBase: './',
      amdLanguageBase: './i18n/',
      closeOnSelect: true,
      debug: false,
      dropdownAutoWidth: false,
      escapeMarkup: Utils.escapeMarkup,
      language: EnglishTranslation,
      matcher: matcher,
      minimumInputLength: 0,
      maximumInputLength: 0,
      maximumSelectionLength: 0,
      minimumResultsForSearch: 0,
      selectOnClose: false,
      sorter: function (data) {
        return data;
      },
      templateResult: function (result) {
        return result.text;
      },
      templateSelection: function (selection) {
        return selection.text;
      },
      theme: 'default',
      width: 'resolve'
    };
  };

  Defaults.prototype.set = function (key, value) {
    var camelKey = $.camelCase(key);

    var data = {};
    data[camelKey] = value;

    var convertedData = Utils._convertData(data);

    $.extend(true, this.defaults, convertedData);
  };

  var defaults = new Defaults();

  return defaults;
});

S2.define('select2/options',[
  'require',
  'jquery',
  './defaults',
  './utils'
], function (require, $, Defaults, Utils) {
  function Options (options, $element) {
    this.options = options;

    if ($element != null) {
      this.fromElement($element);
    }

    this.options = Defaults.apply(this.options);

    if ($element && $element.is('input')) {
      var InputCompat = require(this.get('amdBase') + 'compat/inputData');

      this.options.dataAdapter = Utils.Decorate(
        this.options.dataAdapter,
        InputCompat
      );
    }
  }

  Options.prototype.fromElement = function ($e) {
    var excludedData = ['select2'];

    if (this.options.multiple == null) {
      this.options.multiple = $e.prop('multiple');
    }

    if (this.options.disabled == null) {
      this.options.disabled = $e.prop('disabled');
    }

    if (this.options.language == null) {
      if ($e.prop('lang')) {
        this.options.language = $e.prop('lang').toLowerCase();
      } else if ($e.closest('[lang]').prop('lang')) {
        this.options.language = $e.closest('[lang]').prop('lang');
      }
    }

    if (this.options.dir == null) {
      if ($e.prop('dir')) {
        this.options.dir = $e.prop('dir');
      } else if ($e.closest('[dir]').prop('dir')) {
        this.options.dir = $e.closest('[dir]').prop('dir');
      } else {
        this.options.dir = 'ltr';
      }
    }

    $e.prop('disabled', this.options.disabled);
    $e.prop('multiple', this.options.multiple);

    if (Utils.GetData($e[0], 'select2Tags')) {
      if (this.options.debug && window.console && console.warn) {
        console.warn(
          'Select2: The `data-select2-tags` attribute has been changed to ' +
          'use the `data-data` and `data-tags="true"` attributes and will be ' +
          'removed in future versions of Select2.'
        );
      }

      Utils.StoreData($e[0], 'data', Utils.GetData($e[0], 'select2Tags'));
      Utils.StoreData($e[0], 'tags', true);
    }

    if (Utils.GetData($e[0], 'ajaxUrl')) {
      if (this.options.debug && window.console && console.warn) {
        console.warn(
          'Select2: The `data-ajax-url` attribute has been changed to ' +
          '`data-ajax--url` and support for the old attribute will be removed' +
          ' in future versions of Select2.'
        );
      }

      $e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
      Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));
	  
    }

    var dataset = {};

    // Prefer the element's `dataset` attribute if it exists
    // jQuery 1.x does not correctly handle data attributes with multiple dashes
    if ($.fn.jquery && $.fn.jquery.substr(0, 2) == '1.' && $e[0].dataset) {
      dataset = $.extend(true, {}, $e[0].dataset, Utils.GetData($e[0]));
    } else {
      dataset = Utils.GetData($e[0]);
    }

    var data = $.extend(true, {}, dataset);

    data = Utils._convertData(data);

    for (var key in data) {
      if ($.inArray(key, excludedData) > -1) {
        continue;
      }

      if ($.isPlainObject(this.options[key])) {
        $.extend(this.options[key], data[key]);
      } else {
        this.options[key] = data[key];
      }
    }

    return this;
  };

  Options.prototype.get = function (key) {
    return this.options[key];
  };

  Options.prototype.set = function (key, val) {
    this.options[key] = val;
  };

  return Options;
});

S2.define('select2/core',[
  'jquery',
  './options',
  './utils',
  './keys'
], function ($, Options, Utils, KEYS) {
  var Select2 = function ($element, options) {
    if (Utils.GetData($element[0], 'select2') != null) {
      Utils.GetData($element[0], 'select2').destroy();
    }

    this.$element = $element;

    this.id = this._generateId($element);

    options = options || {};

    this.options = new Options(options, $element);

    Select2.__super__.constructor.call(this);

    // Set up the tabindex

    var tabindex = $element.attr('tabindex') || 0;
    Utils.StoreData($element[0], 'old-tabindex', tabindex);
    $element.attr('tabindex', '-1');

    // Set up containers and adapters

    var DataAdapter = this.options.get('dataAdapter');
    this.dataAdapter = new DataAdapter($element, this.options);

    var $container = this.render();

    this._placeContainer($container);

    var SelectionAdapter = this.options.get('selectionAdapter');
    this.selection = new SelectionAdapter($element, this.options);
    this.$selection = this.selection.render();

    this.selection.position(this.$selection, $container);

    var DropdownAdapter = this.options.get('dropdownAdapter');
    this.dropdown = new DropdownAdapter($element, this.options);
    this.$dropdown = this.dropdown.render();

    this.dropdown.position(this.$dropdown, $container);

    var ResultsAdapter = this.options.get('resultsAdapter');
    this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
    this.$results = this.results.render();

    this.results.position(this.$results, this.$dropdown);

    // Bind events

    var self = this;

    // Bind the container to all of the adapters
    this._bindAdapters();

    // Register any DOM event handlers
    this._registerDomEvents();

    // Register any internal event handlers
    this._registerDataEvents();
    this._registerSelectionEvents();
    this._registerDropdownEvents();
    this._registerResultsEvents();
    this._registerEvents();

    // Set the initial state
    this.dataAdapter.current(function (initialData) {
      self.trigger('selection:update', {
        data: initialData
      });
    });

    // Hide the original select
    $element.addClass('select2-hidden-accessible');
    $element.attr('aria-hidden', 'true');

    // Synchronize any monitored attributes
    this._syncAttributes();

    Utils.StoreData($element[0], 'select2', this);

    // Ensure backwards compatibility with $element.data('select2').
    $element.data('select2', this);
  };

  Utils.Extend(Select2, Utils.Observable);

  Select2.prototype._generateId = function ($element) {
    var id = '';

    if ($element.attr('id') != null) {
      id = $element.attr('id');
    } else if ($element.attr('name') != null) {
      id = $element.attr('name') + '-' + Utils.generateChars(2);
    } else {
      id = Utils.generateChars(4);
    }

    id = id.replace(/(:|\.|\[|\]|,)/g, '');
    id = 'select2-' + id;

    return id;
  };

  Select2.prototype._placeContainer = function ($container) {
    $container.insertAfter(this.$element);

    var width = this._resolveWidth(this.$element, this.options.get('width'));

    if (width != null) {
      $container.css('width', width);
    }
  };

  Select2.prototype._resolveWidth = function ($element, method) {
    var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;

    if (method == 'resolve') {
      var styleWidth = this._resolveWidth($element, 'style');

      if (styleWidth != null) {
        return styleWidth;
      }

      return this._resolveWidth($element, 'element');
    }

    if (method == 'element') {
      var elementWidth = $element.outerWidth(false);

      if (elementWidth <= 0) {
        return 'auto';
      }

      return elementWidth + 'px';
    }

    if (method == 'style') {
      var style = $element.attr('style');

      if (typeof(style) !== 'string') {
        return null;
      }

      var attrs = style.split(';');

      for (var i = 0, l = attrs.length; i < l; i = i + 1) {
        var attr = attrs[i].replace(/\s/g, '');
        var matches = attr.match(WIDTH);

        if (matches !== null && matches.length >= 1) {
          return matches[1];
        }
      }

      return null;
    }

    return method;
  };

  Select2.prototype._bindAdapters = function () {
    this.dataAdapter.bind(this, this.$container);
    this.selection.bind(this, this.$container);

    this.dropdown.bind(this, this.$container);
    this.results.bind(this, this.$container);
  };

  Select2.prototype._registerDomEvents = function () {
    var self = this;

    this.$element.on('change.select2', function () {
      self.dataAdapter.current(function (data) {
        self.trigger('selection:update', {
          data: data
        });
      });
    });

    this.$element.on('focus.select2', function (evt) {
      self.trigger('focus', evt);
    });

    this._syncA = Utils.bind(this._syncAttributes, this);
    this._syncS = Utils.bind(this._syncSubtree, this);

    if (this.$element[0].attachEvent) {
      this.$element[0].attachEvent('onpropertychange', this._syncA);
    }

    var observer = window.MutationObserver ||
      window.WebKitMutationObserver ||
      window.MozMutationObserver
    ;

    if (observer != null) {
      this._observer = new observer(function (mutations) {
        $.each(mutations, self._syncA);
        $.each(mutations, self._syncS);
      });
      this._observer.observe(this.$element[0], {
        attributes: true,
        childList: true,
        subtree: false
      });
    } else if (this.$element[0].addEventListener) {
      this.$element[0].addEventListener(
        'DOMAttrModified',
        self._syncA,
        false
      );
      this.$element[0].addEventListener(
        'DOMNodeInserted',
        self._syncS,
        false
      );
      this.$element[0].addEventListener(
        'DOMNodeRemoved',
        self._syncS,
        false
      );
    }
  };

  Select2.prototype._registerDataEvents = function () {
    var self = this;

    this.dataAdapter.on('*', function (name, params) {
      self.trigger(name, params);
    });
  };

  Select2.prototype._registerSelectionEvents = function () {
    var self = this;
    var nonRelayEvents = ['toggle', 'focus'];

    this.selection.on('toggle', function () {
      self.toggleDropdown();
    });

    this.selection.on('focus', function (params) {
      self.focus(params);
    });

    this.selection.on('*', function (name, params) {
      if ($.inArray(name, nonRelayEvents) !== -1) {
        return;
      }

      self.trigger(name, params);
    });
  };

  Select2.prototype._registerDropdownEvents = function () {
    var self = this;

    this.dropdown.on('*', function (name, params) {
      self.trigger(name, params);
    });
  };

  Select2.prototype._registerResultsEvents = function () {
    var self = this;

    this.results.on('*', function (name, params) {
      self.trigger(name, params);
    });
  };

  Select2.prototype._registerEvents = function () {
    var self = this;

    this.on('open', function () {
      self.$container.addClass('select2-container--open');
    });

    this.on('close', function () {
      self.$container.removeClass('select2-container--open');
    });

    this.on('enable', function () {
      self.$container.removeClass('select2-container--disabled');
    });

    this.on('disable', function () {
      self.$container.addClass('select2-container--disabled');
    });

    this.on('blur', function () {
      self.$container.removeClass('select2-container--focus');
    });

    this.on('query', function (params) {
      if (!self.isOpen()) {
        self.trigger('open', {});
      }

      this.dataAdapter.query(params, function (data) {
        self.trigger('results:all', {
          data: data,
          query: params
        });
      });
    });

    this.on('query:append', function (params) {
      this.dataAdapter.query(params, function (data) {
        self.trigger('results:append', {
          data: data,
          query: params
        });
      });
    });

    this.on('keypress', function (evt) {
      var key = evt.which;

      if (self.isOpen()) {
        if (key === KEYS.ESC || key === KEYS.TAB ||
            (key === KEYS.UP && evt.altKey)) {
          self.close();

          evt.preventDefault();
        } else if (key === KEYS.ENTER) {
          self.trigger('results:select', {});

          evt.preventDefault();
        } else if ((key === KEYS.SPACE && evt.ctrlKey)) {
          self.trigger('results:toggle', {});

          evt.preventDefault();
        } else if (key === KEYS.UP) {
          self.trigger('results:previous', {});

          evt.preventDefault();
        } else if (key === KEYS.DOWN) {
          self.trigger('results:next', {});

          evt.preventDefault();
        }
      } else {
        if (key === KEYS.ENTER || key === KEYS.SPACE ||
            (key === KEYS.DOWN && evt.altKey)) {
          self.open();

          evt.preventDefault();
        }
      }
    });
  };

  Select2.prototype._syncAttributes = function () {
    this.options.set('disabled', this.$element.prop('disabled'));

    if (this.options.get('disabled')) {
      if (this.isOpen()) {
        this.close();
      }

      this.trigger('disable', {});
    } else {
      this.trigger('enable', {});
    }
  };

  Select2.prototype._syncSubtree = function (evt, mutations) {
    var changed = false;
    var self = this;

    // Ignore any mutation events raised for elements that aren't options or
    // optgroups. This handles the case when the select element is destroyed
    if (
      evt && evt.target && (
        evt.target.nodeName !== 'OPTION' && evt.target.nodeName !== 'OPTGROUP'
      )
    ) {
      return;
    }

    if (!mutations) {
      // If mutation events aren't supported, then we can only assume that the
      // change affected the selections
      changed = true;
    } else if (mutations.addedNodes && mutations.addedNodes.length > 0) {
      for (var n = 0; n < mutations.addedNodes.length; n++) {
        var node = mutations.addedNodes[n];

        if (node.selected) {
          changed = true;
        }
      }
    } else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
      changed = true;
    }

    // Only re-pull the data if we think there is a change
    if (changed) {
      this.dataAdapter.current(function (currentData) {
        self.trigger('selection:update', {
          data: currentData
        });
      });
    }
  };

  /**
   * Override the trigger method to automatically trigger pre-events when
   * there are events that can be prevented.
   */
  Select2.prototype.trigger = function (name, args) {
    var actualTrigger = Select2.__super__.trigger;
    var preTriggerMap = {
      'open': 'opening',
      'close': 'closing',
      'select': 'selecting',
      'unselect': 'unselecting',
      'clear': 'clearing'
    };

    if (args === undefined) {
      args = {};
    }

    if (name in preTriggerMap) {
      var preTriggerName = preTriggerMap[name];
      var preTriggerArgs = {
        prevented: false,
        name: name,
        args: args
      };

      actualTrigger.call(this, preTriggerName, preTriggerArgs);

      if (preTriggerArgs.prevented) {
        args.prevented = true;

        return;
      }
    }

    actualTrigger.call(this, name, args);
  };

  Select2.prototype.toggleDropdown = function () {
    if (this.options.get('disabled')) {
      return;
    }

    if (this.isOpen()) {
      this.close();
    } else {
      this.open();
    }
  };

  Select2.prototype.open = function () {
    if (this.isOpen()) {
      return;
    }

    this.trigger('query', {});
  };

  Select2.prototype.close = function () {
    if (!this.isOpen()) {
      return;
    }

    this.trigger('close', {});
  };

  Select2.prototype.isOpen = function () {
    return this.$container.hasClass('select2-container--open');
  };

  Select2.prototype.hasFocus = function () {
    return this.$container.hasClass('select2-container--focus');
  };

  Select2.prototype.focus = function (data) {
    // No need to re-trigger focus events if we are already focused
    if (this.hasFocus()) {
      return;
    }

    this.$container.addClass('select2-container--focus');
    this.trigger('focus', {});
  };

  Select2.prototype.enable = function (args) {
    if (this.options.get('debug') && window.console && console.warn) {
      console.warn(
        'Select2: The `select2("enable")` method has been deprecated and will' +
        ' be removed in later Select2 versions. Use $element.prop("disabled")' +
        ' instead.'
      );
    }

    if (args == null || args.length === 0) {
      args = [true];
    }

    var disabled = !args[0];

    this.$element.prop('disabled', disabled);
  };

  Select2.prototype.data = function () {
    if (this.options.get('debug') &&
        arguments.length > 0 && window.console && console.warn) {
      console.warn(
        'Select2: Data can no longer be set using `select2("data")`. You ' +
        'should consider setting the value instead using `$element.val()`.'
      );
    }

    var data = [];

    this.dataAdapter.current(function (currentData) {
      data = currentData;
    });

    return data;
  };

  Select2.prototype.val = function (args) {
    if (this.options.get('debug') && window.console && console.warn) {
      console.warn(
        'Select2: The `select2("val")` method has been deprecated and will be' +
        ' removed in later Select2 versions. Use $element.val() instead.'
      );
    }

    if (args == null || args.length === 0) {
      return this.$element.val();
    }

    var newVal = args[0];

    if ($.isArray(newVal)) {
      newVal = $.map(newVal, function (obj) {
        return obj.toString();
      });
    }

    this.$element.val(newVal).trigger('change');
  };

  Select2.prototype.destroy = function () {
    this.$container.remove();

    if (this.$element[0].detachEvent) {
      this.$element[0].detachEvent('onpropertychange', this._syncA);
    }

    if (this._observer != null) {
      this._observer.disconnect();
      this._observer = null;
    } else if (this.$element[0].removeEventListener) {
      this.$element[0]
        .removeEventListener('DOMAttrModified', this._syncA, false);
      this.$element[0]
        .removeEventListener('DOMNodeInserted', this._syncS, false);
      this.$element[0]
        .removeEventListener('DOMNodeRemoved', this._syncS, false);
    }

    this._syncA = null;
    this._syncS = null;

    this.$element.off('.select2');
    this.$element.attr('tabindex',
    Utils.GetData(this.$element[0], 'old-tabindex'));

    this.$element.removeClass('select2-hidden-accessible');
    this.$element.attr('aria-hidden', 'false');
    Utils.RemoveData(this.$element[0]);
    this.$element.removeData('select2');

    this.dataAdapter.destroy();
    this.selection.destroy();
    this.dropdown.destroy();
    this.results.destroy();

    this.dataAdapter = null;
    this.selection = null;
    this.dropdown = null;
    this.results = null;
  };

  Select2.prototype.render = function () {
    var $container = $(
      '<span class="select2 select2-container">' +
        '<span class="selection"></span>' +
        '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
      '</span>'
    );

    $container.attr('dir', this.options.get('dir'));

    this.$container = $container;

    this.$container.addClass('select2-container--' + this.options.get('theme'));

    Utils.StoreData($container[0], 'element', this.$element);

    return $container;
  };

  return Select2;
});

S2.define('select2/compat/utils',[
  'jquery'
], function ($) {
  function syncCssClasses ($dest, $src, adapter) {
    var classes, replacements = [], adapted;

    classes = $.trim($dest.attr('class'));

    if (classes) {
      classes = '' + classes; // for IE which returns object

      $(classes.split(/\s+/)).each(function () {
        // Save all Select2 classes
        if (this.indexOf('select2-') === 0) {
          replacements.push(this);
        }
      });
    }

    classes = $.trim($src.attr('class'));

    if (classes) {
      classes = '' + classes; // for IE which returns object

      $(classes.split(/\s+/)).each(function () {
        // Only adapt non-Select2 classes
        if (this.indexOf('select2-') !== 0) {
          adapted = adapter(this);

          if (adapted != null) {
            replacements.push(adapted);
          }
        }
      });
    }

    $dest.attr('class', replacements.join(' '));
  }

  return {
    syncCssClasses: syncCssClasses
  };
});

S2.define('select2/compat/containerCss',[
  'jquery',
  './utils'
], function ($, CompatUtils) {
  // No-op CSS adapter that discards all classes by default
  function _containerAdapter (clazz) {
    return null;
  }

  function ContainerCSS () { }

  ContainerCSS.prototype.render = function (decorated) {
    var $container = decorated.call(this);

    var containerCssClass = this.options.get('containerCssClass') || '';

    if ($.isFunction(containerCssClass)) {
      containerCssClass = containerCssClass(this.$element);
    }

    var containerCssAdapter = this.options.get('adaptContainerCssClass');
    containerCssAdapter = containerCssAdapter || _containerAdapter;

    if (containerCssClass.indexOf(':all:') !== -1) {
      containerCssClass = containerCssClass.replace(':all:', '');

      var _cssAdapter = containerCssAdapter;

      containerCssAdapter = function (clazz) {
        var adapted = _cssAdapter(clazz);

        if (adapted != null) {
          // Append the old one along with the adapted one
          return adapted + ' ' + clazz;
        }

        return clazz;
      };
    }

    var containerCss = this.options.get('containerCss') || {};

    if ($.isFunction(containerCss)) {
      containerCss = containerCss(this.$element);
    }

    CompatUtils.syncCssClasses($container, this.$element, containerCssAdapter);

    $container.css(containerCss);
    $container.addClass(containerCssClass);

    return $container;
  };

  return ContainerCSS;
});

S2.define('select2/compat/dropdownCss',[
  'jquery',
  './utils'
], function ($, CompatUtils) {
  // No-op CSS adapter that discards all classes by default
  function _dropdownAdapter (clazz) {
    return null;
  }

  function DropdownCSS () { }

  DropdownCSS.prototype.render = function (decorated) {
    var $dropdown = decorated.call(this);

    var dropdownCssClass = this.options.get('dropdownCssClass') || '';

    if ($.isFunction(dropdownCssClass)) {
      dropdownCssClass = dropdownCssClass(this.$element);
    }

    var dropdownCssAdapter = this.options.get('adaptDropdownCssClass');
    dropdownCssAdapter = dropdownCssAdapter || _dropdownAdapter;

    if (dropdownCssClass.indexOf(':all:') !== -1) {
      dropdownCssClass = dropdownCssClass.replace(':all:', '');

      var _cssAdapter = dropdownCssAdapter;

      dropdownCssAdapter = function (clazz) {
        var adapted = _cssAdapter(clazz);

        if (adapted != null) {
          // Append the old one along with the adapted one
          return adapted + ' ' + clazz;
        }

        return clazz;
      };
    }

    var dropdownCss = this.options.get('dropdownCss') || {};

    if ($.isFunction(dropdownCss)) {
      dropdownCss = dropdownCss(this.$element);
    }

    CompatUtils.syncCssClasses($dropdown, this.$element, dropdownCssAdapter);

    $dropdown.css(dropdownCss);
    $dropdown.addClass(dropdownCssClass);

    return $dropdown;
  };

  return DropdownCSS;
});

S2.define('select2/compat/initSelection',[
  'jquery'
], function ($) {
  function InitSelection (decorated, $element, options) {
    if (options.get('debug') && window.console && console.warn) {
      console.warn(
        'Select2: The `initSelection` option has been deprecated in favor' +
        ' of a custom data adapter that overrides the `current` method. ' +
        'This method is now called multiple times instead of a single ' +
        'time when the instance is initialized. Support will be removed ' +
        'for the `initSelection` option in future versions of Select2'
      );
    }

    this.initSelection = options.get('initSelection');
    this._isInitialized = false;

    decorated.call(this, $element, options);
  }

  InitSelection.prototype.current = function (decorated, callback) {
    var self = this;

    if (this._isInitialized) {
      decorated.call(this, callback);

      return;
    }

    this.initSelection.call(null, this.$element, function (data) {
      self._isInitialized = true;

      if (!$.isArray(data)) {
        data = [data];
      }

      callback(data);
    });
  };

  return InitSelection;
});

S2.define('select2/compat/inputData',[
  'jquery',
  '../utils'
], function ($, Utils) {
  function InputData (decorated, $element, options) {
    this._currentData = [];
    this._valueSeparator = options.get('valueSeparator') || ',';

    if ($element.prop('type') === 'hidden') {
      if (options.get('debug') && console && console.warn) {
        console.warn(
          'Select2: Using a hidden input with Select2 is no longer ' +
          'supported and may stop working in the future. It is recommended ' +
          'to use a `<select>` element instead.'
        );
      }
    }

    decorated.call(this, $element, options);
  }

  InputData.prototype.current = function (_, callback) {
    function getSelected (data, selectedIds) {
      var selected = [];

      if (data.selected || $.inArray(data.id, selectedIds) !== -1) {
        data.selected = true;
        selected.push(data);
      } else {
        data.selected = false;
      }

      if (data.children) {
        selected.push.apply(selected, getSelected(data.children, selectedIds));
      }

      return selected;
    }

    var selected = [];

    for (var d = 0; d < this._currentData.length; d++) {
      var data = this._currentData[d];

      selected.push.apply(
        selected,
        getSelected(
          data,
          this.$element.val().split(
            this._valueSeparator
          )
        )
      );
    }

    callback(selected);
  };

  InputData.prototype.select = function (_, data) {
    if (!this.options.get('multiple')) {
      this.current(function (allData) {
        $.map(allData, function (data) {
          data.selected = false;
        });
      });

      this.$element.val(data.id);
      this.$element.trigger('change');
    } else {
      var value = this.$element.val();
      value += this._valueSeparator + data.id;

      this.$element.val(value);
      this.$element.trigger('change');
    }
  };

  InputData.prototype.unselect = function (_, data) {
    var self = this;

    data.selected = false;

    this.current(function (allData) {
      var values = [];

      for (var d = 0; d < allData.length; d++) {
        var item = allData[d];

        if (data.id == item.id) {
          continue;
        }

        values.push(item.id);
      }

      self.$element.val(values.join(self._valueSeparator));
      self.$element.trigger('change');
    });
  };

  InputData.prototype.query = function (_, params, callback) {
    var results = [];

    for (var d = 0; d < this._currentData.length; d++) {
      var data = this._currentData[d];

      var matches = this.matches(params, data);

      if (matches !== null) {
        results.push(matches);
      }
    }

    callback({
      results: results
    });
  };

  InputData.prototype.addOptions = function (_, $options) {
    var options = $.map($options, function ($option) {
      return Utils.GetData($option[0], 'data');
    });

    this._currentData.push.apply(this._currentData, options);
  };

  return InputData;
});

S2.define('select2/compat/matcher',[
  'jquery'
], function ($) {
  function oldMatcher (matcher) {
    function wrappedMatcher (params, data) {
      var match = $.extend(true, {}, data);

      if (params.term == null || $.trim(params.term) === '') {
        return match;
      }

      if (data.children) {
        for (var c = data.children.length - 1; c >= 0; c--) {
          var child = data.children[c];

          // Check if the child object matches
          // The old matcher returned a boolean true or false
          var doesMatch = matcher(params.term, child.text, child);

          // If the child didn't match, pop it off
          if (!doesMatch) {
            match.children.splice(c, 1);
          }
        }

        if (match.children.length > 0) {
          return match;
        }
      }

      if (matcher(params.term, data.text, data)) {
        return match;
      }

      return null;
    }

    return wrappedMatcher;
  }

  return oldMatcher;
});

S2.define('select2/compat/query',[

], function () {
  function Query (decorated, $element, options) {
    if (options.get('debug') && window.console && console.warn) {
      console.warn(
        'Select2: The `query` option has been deprecated in favor of a ' +
        'custom data adapter that overrides the `query` method. Support ' +
        'will be removed for the `query` option in future versions of ' +
        'Select2.'
      );
    }

    decorated.call(this, $element, options);
  }

  Query.prototype.query = function (_, params, callback) {
    params.callback = callback;

    var query = this.options.get('query');

    query.call(null, params);
  };

  return Query;
});

S2.define('select2/dropdown/attachContainer',[

], function () {
  function AttachContainer (decorated, $element, options) {
    decorated.call(this, $element, options);
  }

  AttachContainer.prototype.position =
    function (decorated, $dropdown, $container) {
    var $dropdownContainer = $container.find('.dropdown-wrapper');
    $dropdownContainer.append($dropdown);

    $dropdown.addClass('select2-dropdown--below');
    $container.addClass('select2-container--below');
  };

  return AttachContainer;
});

S2.define('select2/dropdown/stopPropagation',[

], function () {
  function StopPropagation () { }

  StopPropagation.prototype.bind = function (decorated, container, $container) {
    decorated.call(this, container, $container);

    var stoppedEvents = [
    'blur',
    'change',
    'click',
    'dblclick',
    'focus',
    'focusin',
    'focusout',
    'input',
    'keydown',
    'keyup',
    'keypress',
    'mousedown',
    'mouseenter',
    'mouseleave',
    'mousemove',
    'mouseover',
    'mouseup',
    'search',
    'touchend',
    'touchstart'
    ];

    this.$dropdown.on(stoppedEvents.join(' '), function (evt) {
      evt.stopPropagation();
    });
  };

  return StopPropagation;
});

S2.define('select2/selection/stopPropagation',[

], function () {
  function StopPropagation () { }

  StopPropagation.prototype.bind = function (decorated, container, $container) {
    decorated.call(this, container, $container);

    var stoppedEvents = [
      'blur',
      'change',
      'click',
      'dblclick',
      'focus',
      'focusin',
      'focusout',
      'input',
      'keydown',
      'keyup',
      'keypress',
      'mousedown',
      'mouseenter',
      'mouseleave',
      'mousemove',
      'mouseover',
      'mouseup',
      'search',
      'touchend',
      'touchstart'
    ];

    this.$selection.on(stoppedEvents.join(' '), function (evt) {
      evt.stopPropagation();
    });
  };

  return StopPropagation;
});

/*!
 * jQuery Mousewheel 3.1.13
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 */

(function (factory) {
    if ( typeof S2.define === 'function' && S2.define.amd ) {
        // AMD. Register as an anonymous module.
        S2.define('jquery-mousewheel',['jquery'], factory);
    } else if (typeof exports === 'object') {
        // Node/CommonJS style for Browserify
        module.exports = factory;
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function ($) {

    var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
        toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
                    ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
        slice  = Array.prototype.slice,
        nullLowestDeltaTimeout, lowestDelta;

    if ( $.event.fixHooks ) {
        for ( var i = toFix.length; i; ) {
            $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
        }
    }

    var special = $.event.special.mousewheel = {
        version: '3.1.12',

        setup: function() {
            if ( this.addEventListener ) {
                for ( var i = toBind.length; i; ) {
                    this.addEventListener( toBind[--i], handler, false );
                }
            } else {
                this.onmousewheel = handler;
            }
            // Store the line height and page height for this particular element
            $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
            $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
        },

        teardown: function() {
            if ( this.removeEventListener ) {
                for ( var i = toBind.length; i; ) {
                    this.removeEventListener( toBind[--i], handler, false );
                }
            } else {
                this.onmousewheel = null;
            }
            // Clean up the data we added to the element
            $.removeData(this, 'mousewheel-line-height');
            $.removeData(this, 'mousewheel-page-height');
        },

        getLineHeight: function(elem) {
            var $elem = $(elem),
                $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
            if (!$parent.length) {
                $parent = $('body');
            }
            return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
        },

        getPageHeight: function(elem) {
            return $(elem).height();
        },

        settings: {
            adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
            normalizeOffset: true  // calls getBoundingClientRect for each event
        }
    };

    $.fn.extend({
        mousewheel: function(fn) {
            return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
        },

        unmousewheel: function(fn) {
            return this.unbind('mousewheel', fn);
        }
    });


    function handler(event) {
        var orgEvent   = event || window.event,
            args       = slice.call(arguments, 1),
            delta      = 0,
            deltaX     = 0,
            deltaY     = 0,
            absDelta   = 0,
            offsetX    = 0,
            offsetY    = 0;
        event = $.event.fix(orgEvent);
        event.type = 'mousewheel';

        // Old school scrollwheel delta
        if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }
        if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }
        if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }
        if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }

        // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
        if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
            deltaX = deltaY * -1;
            deltaY = 0;
        }

        // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
        delta = deltaY === 0 ? deltaX : deltaY;

        // New school wheel delta (wheel event)
        if ( 'deltaY' in orgEvent ) {
            deltaY = orgEvent.deltaY * -1;
            delta  = deltaY;
        }
        if ( 'deltaX' in orgEvent ) {
            deltaX = orgEvent.deltaX;
            if ( deltaY === 0 ) { delta  = deltaX * -1; }
        }

        // No change actually happened, no reason to go any further
        if ( deltaY === 0 && deltaX === 0 ) { return; }

        // Need to convert lines and pages to pixels if we aren't already in pixels
        // There are three delta modes:
        //   * deltaMode 0 is by pixels, nothing to do
        //   * deltaMode 1 is by lines
        //   * deltaMode 2 is by pages
        if ( orgEvent.deltaMode === 1 ) {
            var lineHeight = $.data(this, 'mousewheel-line-height');
            delta  *= lineHeight;
            deltaY *= lineHeight;
            deltaX *= lineHeight;
        } else if ( orgEvent.deltaMode === 2 ) {
            var pageHeight = $.data(this, 'mousewheel-page-height');
            delta  *= pageHeight;
            deltaY *= pageHeight;
            deltaX *= pageHeight;
        }

        // Store lowest absolute delta to normalize the delta values
        absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );

        if ( !lowestDelta || absDelta < lowestDelta ) {
            lowestDelta = absDelta;

            // Adjust older deltas if necessary
            if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
                lowestDelta /= 40;
            }
        }

        // Adjust older deltas if necessary
        if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
            // Divide all the things by 40!
            delta  /= 40;
            deltaX /= 40;
            deltaY /= 40;
        }

        // Get a whole, normalized value for the deltas
        delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);
        deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
        deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);

        // Normalise offsetX and offsetY properties
        if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
            var boundingRect = this.getBoundingClientRect();
            offsetX = event.clientX - boundingRect.left;
            offsetY = event.clientY - boundingRect.top;
        }

        // Add information to the event object
        event.deltaX = deltaX;
        event.deltaY = deltaY;
        event.deltaFactor = lowestDelta;
        event.offsetX = offsetX;
        event.offsetY = offsetY;
        // Go ahead and set deltaMode to 0 since we converted to pixels
        // Although this is a little odd since we overwrite the deltaX/Y
        // properties with normalized deltas.
        event.deltaMode = 0;

        // Add event and delta to the front of the arguments
        args.unshift(event, delta, deltaX, deltaY);

        // Clearout lowestDelta after sometime to better
        // handle multiple device types that give different
        // a different lowestDelta
        // Ex: trackpad = 3 and mouse wheel = 120
        if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
        nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);

        return ($.event.dispatch || $.event.handle).apply(this, args);
    }

    function nullLowestDelta() {
        lowestDelta = null;
    }

    function shouldAdjustOldDeltas(orgEvent, absDelta) {
        // If this is an older event and the delta is divisable by 120,
        // then we are assuming that the browser is treating this as an
        // older mouse wheel event and that we should divide the deltas
        // by 40 to try and get a more usable deltaFactor.
        // Side note, this actually impacts the reported scroll distance
        // in older browsers and can cause scrolling to be slower than native.
        // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
        return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
    }

}));

S2.define('jquery.select2',[
  'jquery',
  'jquery-mousewheel',

  './select2/core',
  './select2/defaults',
  './select2/utils'
], function ($, _, Select2, Defaults, Utils) {
  if ($.fn.select2 == null) {
    // All methods that should return the element
    var thisMethods = ['open', 'close', 'destroy'];

    $.fn.select2 = function (options) {
      options = options || {};

      if (typeof options === 'object') {
        this.each(function () {
          var instanceOptions = $.extend(true, {}, options);

          var instance = new Select2($(this), instanceOptions);
        });

        return this;
      } else if (typeof options === 'string') {
        var ret;
        var args = Array.prototype.slice.call(arguments, 1);

        this.each(function () {
          var instance = Utils.GetData(this, 'select2');

          if (instance == null && window.console && console.error) {
            console.error(
              'The select2(\'' + options + '\') method was called on an ' +
              'element that is not using Select2.'
            );
          }

          ret = instance[options].apply(instance, args);
        });

        // Check if we should be returning `this`
        if ($.inArray(options, thisMethods) > -1) {
          return this;
        }

        return ret;
      } else {
        throw new Error('Invalid arguments for Select2: ' + options);
      }
    };
  }

  if ($.fn.select2.defaults == null) {
    $.fn.select2.defaults = Defaults;
  }

  return Select2;
});

  // Return the AMD loader configuration so it can be used outside of this file
  return {
    define: S2.define,
    require: S2.require
  };
}());

  // Autoload the jQuery bindings
  // We know that all of the modules exist above this, so we're safe
  var select2 = S2.require('jquery.select2');

  // Hold the AMD module references on the jQuery function that was just loaded
  // This allows Select2 to use the internal loader outside of this file, such
  // as in the language files.
  jQuery.fn.select2.amd = S2;

  // Return the Select2 instance for anyone who is importing it.
  return select2;
}));
metabox/class-bloglo-meta-boxes.php000064400000047226152425717710013365 0ustar00<?php
/**
 * Meta Boxes class.
 *
 * @package     Bloglo
 * @author      Peregrine Themes
 * @since       1.0.0
 */

/**
 * Do not allow direct script access.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Bloglo_Meta_Boxes' ) ) :

	/**
	 * Meta Boxes Class.
	 */
	class Bloglo_Meta_Boxes {

		/**
		 * Singleton instance.
		 *
		 * @since 1.0.0
		 * @var object
		 */
		private static $instance;

		/**
		 * Metabox settings array.
		 *
		 * @since 1.0.0
		 * @var array
		 */
		private $metabox = array();

		/**
		 * Whether this is a new post. Once the post is saved and we're
		 * no longer on the `post-new.php` screen, this is going to be
		 * `false`.
		 *
		 * @since 1.0.0
		 * @var   bool
		 */
		public $is_new_post = false;

		/**
		 * Returns the instance.
		 *
		 * @since  1.0.0
		 */
		public static function get_instance() {

			if ( is_null( self::$instance ) ) {
				self::$instance = new self();
				self::$instance->actions();
			}

			return self::$instance;
		}

		/**
		 * Primary class constructor.
		 *
		 * @since 1.0.0
		 */
		private function __construct() {}

		/**
		 * Sets up initial actions.
		 *
		 * @since  1.0.0
		 */
		private function actions() {

			// Call the register function.
			add_action( 'load-post.php', array( $this, 'register' ) );
			add_action( 'load-post-new.php', array( $this, 'register' ) );

			// Load assets.
			add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );
		}

		/**
		 * Registration callback.
		 *
		 * @since  1.0.0
		 */
		public function register() {

			// If this is a new post, set the new post boolean.
			if ( 'load-post-new.php' === current_action() ) {
				$this->is_new_post = true;
			}

			// Add meta boxes.
			add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 1 );

			// Save settings.
			add_action( 'save_post', array( $this, 'update' ) );

			// Config.
			add_action( 'pre_get_posts', array( $this, 'metabox_config' ) );
		}

		/**
		 * Metabox config array
		 *
		 * @since  1.0.0
		 * @return void
		 */
		public function metabox_config() {

			/**
			 * Layout settings.
			 */
			$layout_settings = array();

			// Sidebar position.
			$layout_settings['bloglo_sidebar_position'] = array(
				'id'      => 'bloglo_sidebar_position',
				'name'    => esc_html__( 'Sidebar', 'bloglo' ),
				'type'    => 'select',
				'default' => 'default',
				'choices' => array(
					''              => esc_html__( 'Default (from Customizer)', 'bloglo' ),
					'no-sidebar'    => esc_html__( 'No Sidebar', 'bloglo' ),
					'left-sidebar'  => esc_html__( 'Left Sidebar', 'bloglo' ),
					'right-sidebar' => esc_html__( 'Right Sidebar', 'bloglo' ),
				),
			);

			// Content layout.
			$layout_settings['bloglo_content_layout'] = array(
				'id'      => 'bloglo_content_layout',
				'name'    => esc_html__( 'Content Layout', 'bloglo' ),
				'type'    => 'select',
				'default' => 'default',
				'choices' => array(
					''             => esc_html__( 'Default (from Customizer)', 'bloglo' ),
					'fw-contained' => esc_html__( 'Full Width: Contained', 'bloglo' ),
					'fw-stretched' => esc_html__( 'Full Width: Stretched', 'bloglo' ),
					'boxed'        => esc_html__( 'Boxed', 'bloglo' ),
				),
			);

			// Transparent header.
			$layout_settings['bloglo_transparent_header'] = array(
				'id'      => 'bloglo_transparent_header',
				'name'    => esc_html__( 'Transparent Header', 'bloglo' ),
				'type'    => 'select',
				'default' => '',
				'choices' => array(
					''        => esc_html__( 'Default (from Customizer)', 'bloglo' ),
					'enable'  => esc_html__( 'Enable', 'bloglo' ),
					'disable' => esc_html__( 'Disable', 'bloglo' ),
				),
			);

			// Start checkbox group.
			$layout_settings['bloglo_page_sections'] = array(
				'id'     => 'bloglo_page_sections',
				'type'   => 'group',
				'fields' => array(),
			);

			// Disable Top Bar.
			if ( bloglo_option( 'top_bar_enable' ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_topbar'] = array(
					'id'      => 'bloglo_disable_topbar',
					'name'    => esc_html__( 'Disable Top Bar', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Header.
			$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_header'] = array(
				'id'      => 'bloglo_disable_header',
				'name'    => esc_html__( 'Disable Main Header', 'bloglo' ),
				'default' => false,
				'type'    => 'checkbox',
			);

			// Disable Page Title.
			if ( bloglo_option( 'page_header_enable' ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_page_title'] = array(
					'id'      => 'bloglo_disable_page_title',
					'name'    => esc_html__( 'Disable Page Title', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Page Breadcrumbs.
			if ( bloglo_option( 'page_header_enable' ) && bloglo_option( 'breadcrumbs_enable' ) && ! bloglo_is_section_disabled( bloglo_option( 'breadcrumbs_hide_on' ), get_the_ID() ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_breadcrumbs'] = array(
					'id'      => 'bloglo_disable_breadcrumbs',
					'name'    => esc_html__( 'Disable Breadcrumbs', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Featured Image.
			$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_thumbnail'] = array(
				'id'      => 'bloglo_disable_thumbnail',
				'name'    => esc_html__( 'Disable Featured Image', 'bloglo' ),
				'default' => false,
				'type'    => 'checkbox',
			);

			// Disable Prefooter.
			if ( bloglo_option( 'enable_pre_footer_cta' ) && ! bloglo_is_section_disabled( bloglo_option( 'pre_footer_cta_hide_on' ), get_the_ID() ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_prefooter_cta'] = array(
					'id'      => 'bloglo_disable_prefooter_cta',
					'name'    => esc_html__( 'Disable Pre Footer CTA', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Footer.
			if ( bloglo_option( 'enable_footer' ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_footer'] = array(
					'id'      => 'bloglo_disable_footer',
					'name'    => esc_html__( 'Disable Main Footer', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Copyright.
			if ( bloglo_option( 'enable_copyright' ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_copyright'] = array(
					'id'      => 'bloglo_disable_copyright',
					'name'    => esc_html__( 'Disable Copyright Bar', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Disable Post Card Border.
			if ( bloglo_option( 'blog_card_border' ) ) {
				$layout_settings['bloglo_page_sections']['fields']['bloglo_disable_blog_card_border'] = array(
					'id'      => 'bloglo_disable_blog_card_border',
					'name'    => esc_html__( 'Disable Post Card Border', 'bloglo' ),
					'default' => false,
					'type'    => 'checkbox',
				);
			}

			// Set metabox options.
			$this->metabox = array(
				'bloglo-theme-page-options' => array(
					'id'         => 'bloglo-theme-page-options',
					'post_type'  => $this->get_post_types(),
					'capability' => 'edit_posts',
					'label'      => esc_html__( 'Theme Page Options', 'bloglo' ),
					'context'    => 'side',
					'priority'   => 'core',
					'settings'   => $layout_settings,
				),
			);

			$this->metabox = apply_filters( 'bloglo_metabox_options', $this->metabox );
		}

		/**
		 * Register Metabox.
		 *
		 * @since 1.0.0
		 * @param string $post_type Post Type of the current post page.
		 */
		public function add_meta_boxes( $post_type ) {

			if ( ! is_array( $this->metabox ) ) {
				return;
			}

			foreach ( $this->metabox as $id => $metabox ) {

				// If the manager is registered for the current post type, add a meta box.
				if ( in_array( $post_type, (array) $metabox['post_type'], true ) && $this->check_capability( $metabox['capability'] ) ) {

					add_meta_box(
						$metabox['id'],
						$metabox['label'],
						array( $this, 'render' ),
						$post_type,
						$metabox['context'],
						$metabox['priority'],
						array( 'settings' => $metabox['settings'] )
					);
				}
			}
		}

		/**
		 * Update Metabox value.
		 *
		 * @since 1.0.0
		 * @param int $post_id Post ID.
		 */
		public function update( $post_id ) {

			$do_autosave = defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE;
			$is_autosave = wp_is_post_autosave( $post_id );
			$is_revision = wp_is_post_revision( $post_id );

			if ( $do_autosave || $is_autosave || $is_revision ) {
				return;
			}

			// Loop through all metaboxes.
			foreach ( $this->metabox as $id => $metabox ) {

				// Capability check.
				if ( $this->check_capability( $metabox['capability'] ) && isset( $_POST[ $metabox['id'] ] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST[ $metabox['id'] ] ) ), $metabox['id'] . '_nonce' ) ) { // phpcs:ignore

					// Loop through metabox settings.
					foreach ( $metabox['settings'] as $setting ) {

						// Group has nested settings.
						if ( 'group' === $setting['type'] ) {
							foreach ( $setting['fields'] as $id => $config ) {
								$this->save_value( $post_id, $config );
							}
						} else {
							$this->save_value( $post_id, $setting );
						}
					}
				}
			}
		}

		/**
		 * Save the new value to postmeta database.
		 *
		 * @since  1.0.0
		 * @param  object $post_id Post object ID.
		 * @param  array  $setting Metabox config array.
		 * @return void
		 */
		public function save_value( $post_id, $setting ) {

			// Get stored value.
			$old_value = $this->get_value( $post_id, $setting );

			// Get new value.
			$new_value = $this->get_posted_value( $setting );

			if ( ! $new_value && $old_value ) {
				delete_post_meta( $post_id, $setting['id'] );
			} elseif ( $new_value !== $old_value ) {
				update_post_meta( $post_id, $setting['id'], $new_value );
			}
		}

		/**
		 * Print the meta box HTML Markup.
		 *
		 * @since  1.0.0
		 * @param  object $post    Post object.
		 * @param  array  $metabox Metabox config array.
		 * @return void
		 */
		public function render( $post, $metabox ) {

			if ( empty( $metabox['args']['settings'] ) ) {
				return;
			}

			foreach ( $metabox['args']['settings'] as $setting ) {

				echo '<div class="bloglo-meta-box-field">';

				if ( isset( $setting['render_field_callback'] ) && function_exists( $setting['render_field_callback'] ) ) {
					call_user_func( $setting['render_field_callback'], $post, $setting );
				} elseif ( method_exists( $this, 'render_field_' . $setting['type'] ) ) {
					call_user_func( array( $this, 'render_field_' . $setting['type'] ), $post, $setting );
				}

				echo '</div>';
			}

			// Nonce field to validate on save.
			wp_nonce_field( $metabox['id'] . '_nonce', $metabox['id'] );
		}

		/**
		 * Render select field.
		 *
		 * @since 1.0.0
		 * @param object $post    Current post object.
		 * @param array  $setting Array of field settings.
		 */
		public function render_field_select( $post, $setting ) {

			$saved_value = get_post_meta( $post->ID, $setting['id'], true );
			?>

			<div class="components-base-control">
				<div class="components-base-control__field">

					<?php if ( isset( $setting['name'] ) ) { ?>
						<label class="post-attributes-label-wrapper components-base-control__label" for="<?php echo esc_attr( $setting['id'] ); ?>">
							<?php echo esc_html( $setting['name'] ); ?>
						</label>
					<?php } ?>

					<select name="<?php echo esc_attr( $setting['id'] ); ?>" id="<?php echo esc_attr( $setting['id'] ); ?>">
						<?php foreach ( $setting['choices'] as $key => $value ) { ?>
							<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $saved_value, $key ); ?>><?php echo esc_html( $value ); ?></option>
						<?php } ?>
					</select>

				</div>
			</div>

			<?php if ( isset( $setting['desc'] ) ) { ?>
				<p class="post-attributes-description-wrapper components-base-control__help description">
					<?php echo esc_html( $setting['desc'] ); ?>
				</p>
			<?php } ?>
			<?php
		}

		/**
		 * Render group of fields.
		 *
		 * @since 1.0.0
		 * @param object $post    Current post object.
		 * @param array  $setting Array of field settings.
		 */
		public function render_field_group( $post, $setting ) {
			?>

			<?php if ( isset( $setting['name'] ) ) { ?>
				<p class="post-attributes-label-wrapper">
					<strong><?php echo esc_html( $setting['name'] ); ?></strong>
				</p>
			<?php } ?>

			<?php if ( isset( $setting['desc'] ) ) { ?>
				<p class="post-attributes-description-wrapper">
					<?php echo esc_html( $setting['desc'] ); ?>
				</p>
			<?php } ?>

			<?php
			foreach ( $setting['fields'] as $key => $value ) {
				if ( method_exists( $this, 'render_field_' . $value['type'] ) ) {
					call_user_func( array( $this, 'render_field_' . $value['type'] ), $post, $value );
				}
			}
		}

		/**
		 * Render checkbox group field.
		 *
		 * @since 1.0.0
		 * @param object $post    Current post object.
		 * @param array  $setting Array of field settings.
		 */
		public function render_field_checkbox( $post, $setting ) {

			$saved = $this->get_value( $post->ID, $setting );
			?>
			<div class="components-panel__row bloglo-checkbox-row">
				<div class="components-base-control">
					<div class="components-base-control__field">
						<span class="components-checkbox-control__input-container bloglo-checkbox-wrapper">
							<input type="checkbox" class="components-checkbox-control__input" id="<?php echo esc_attr( $setting['id'] ); ?>" name="<?php echo esc_attr( $setting['id'] ); ?>"<?php checked( $saved, true ); ?>>
							<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" class="bloglo-checked-icon components-checkbox-control__checked" aria-hidden="true" focusable="false"><path d="M9 18.6L3.5 13l1-1L9 16.4l9.5-9.9 1 1z"></path></svg>
						</span>
						<label class="components-checkbox-control__label" for="<?php echo esc_attr( $setting['id'] ); ?>"><?php echo esc_html( $setting['name'] ); ?></label>
					</div>
				</div>
			</div>
			<?php
		}

		/**
		 * Render textarea field.
		 *
		 * @since 1.0.0
		 * @param object $post    Current post object.
		 * @param array  $setting Array of field settings.
		 */
		public function render_field_textarea( $post, $setting ) {

			$saved = $this->get_value( $post->ID, $setting );
			?>

			<div class="components-base-control">
				<div class="components-base-control__field">

					<?php if ( isset( $setting['name'] ) ) { ?>
						<label class="post-attributes-label-wrapper components-base-control__label" for="<?php echo esc_attr( $setting['id'] ); ?>">
							<?php echo esc_html( $setting['name'] ); ?>
						</label>
					<?php } ?>

					<textarea class="widefat" id="<?php echo esc_attr( $setting['id'] ); ?>" name="<?php echo esc_attr( $setting['id'] ); ?>" rows="5"><?php echo wp_kses_post( $saved ); ?></textarea>

				</div>
			</div>

			<?php if ( isset( $setting['desc'] ) ) { ?>
				<p class="post-attributes-description-wrapper components-base-control__help description">
					<?php echo wp_kses_post( $setting['desc'] ); ?>
				</p>
			<?php } ?>

			<?php
		}

		/**
		 * Render text field.
		 *
		 * @since 1.0.0
		 * @param object $post    Current post object.
		 * @param array  $setting Array of field settings.
		 */
		public function render_field_text( $post, $setting ) {

			$saved = $this->get_value( $post->ID, $setting );
			?>

			<div class="components-base-control">
				<div class="components-base-control__field">

					<?php if ( isset( $setting['name'] ) ) { ?>
						<label class="post-attributes-label-wrapper components-base-control__label" for="<?php echo esc_attr( $setting['id'] ); ?>">
							<?php echo esc_html( $setting['name'] ); ?>
						</label>
					<?php } ?>

					<input type="text" class="widefat" id="<?php echo esc_attr( $setting['id'] ); ?>" name="<?php echo esc_attr( $setting['id'] ); ?>" value="<?php echo wp_kses_post( $saved ); ?>" />

				</div>
			</div>

			<?php if ( isset( $setting['desc'] ) ) { ?>
				<p class="post-attributes-description-wrapper components-base-control__help description">
					<?php echo wp_kses_post( $setting['desc'] ); ?>
				</p>
			<?php } ?>

			<?php
		}

		/**
		 * Load required assets on the admin page(s).
		 *
		 * @since 1.0.0
		 * @param string $hook Current page hook.
		 */
		public function load_assets( $hook ) {

			global $post;

			if ( 'post-new.php' === $hook || 'post.php' === $hook ) {

				$post_type  = $post->post_type;
				$post_types = array();

				foreach ( $this->metabox as $mb ) {
					$post_types = array_merge( $post_types, (array) $mb['post_type'] );
				}

				$post_types = array_unique( $post_types );

				if ( in_array( $post_type, $post_types, true ) ) {

					// Script debug.
					$bloglo_dir    = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
					$bloglo_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

					// Enqueue editor style.
					wp_enqueue_style(
						'bloglo-metabox-style',
						BLOGLO_THEME_URI . '/inc/admin/assets/css/bloglo-meta-boxes' . $bloglo_suffix . '.css',
						false,
						BLOGLO_THEME_VERSION
					);
				}
			}
		}

		/**
		 * Gets the value of the setting.
		 *
		 * @since 1.0.0
		 * @param int   $post_id Post ID.
		 * @param array $setting Array of setting data.
		 */
		public function get_value( $post_id, $setting ) {

			$value = get_post_meta( $post_id, $setting['id'], true );

			return ! $value && $this->is_new_post ? $setting['default'] : $value;
		}

		/**
		 * Gets the posted value of the setting.
		 *
		 * @since 1.0.0
		 * @param array $setting Setting config array.
		 */
		public function get_posted_value( $setting ) {

			$value = '';

			if ( isset( $_POST[ $setting['id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
				$value = wp_unslash( $_POST[ $setting['id'] ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
			}

			return $this->sanitize( $value, $setting );
		}

		/**
		 * Return array of post types for metabox.
		 *
		 * @since 1.0.0
		 * @param array $args Args for get_post_types function.
		 */
		public function get_post_types( $args = false ) {

			if ( ! $args ) {
				$args = array(
					'public' => true,
				);
			}

			$return = get_post_types( $args );

			return $return;
		}

		/**
		 * Sanitizes the value of the setting.
		 *
		 * @since 1.0.0
		 * @param mixed $value   Value of the field to be sanitized.
		 * @param arary $setting Setting config array.
		 */
		public function sanitize( $value, $setting ) {

			$filter = isset( $setting['type'] ) ? $setting['type'] : '';

			switch ( $filter ) {
				case 'select':
					// Ensure input is a slug.
					$value = sanitize_key( $value );

					// Get list of choices from the setting.
					$choices = $setting['choices'];

					// If the input is a valid key, return it; otherwise, return the default.
					$value = array_key_exists( $value, $choices ) ? $value : $setting['default'];
					break;
				case 'checkbox':
					// Ensure boolean value for $value.
					$value = (bool) $value;
					break;
				case 'text':
					$value = sanitize_text_field( $value );
					break;
				case 'textarea':
					$value = wp_kses_post( $value );
					break;
				case 'no_sanitize':
				default:
					break;
			}

			return $value;
		}

		/**
		 * Checks if the control should be allowed at all.
		 *
		 * @since 1.0.0
		 * @param string $cap Capability.
		 */
		public function check_capability( $cap ) {

			if ( ! current_user_can( $cap ) ) {
				return false;
			}

			return true;
		}
	}
endif;

/**
 * The function which returns the one Bloglo Meta Boxes instance.
 *
 * Use this function like you would a global variable, except without needing
 * to declare the global.
 *
 * @since  1.0.0
 * @access public
 * @return object
 */
function bloglo_meta_boxes() {
	return Bloglo_Meta_Boxes::get_instance();
}

bloglo_meta_boxes();
helpers.php000064400000015337152425717710006743 0ustar00<?php
/**
 * Contains various functions that may be potentially used throughout
 * the theme.
 *
 * @package     Bloglo
 * @author      Peregrine Themes
 * @since       1.0.0
 */

/**
 * Do not allow direct script access.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Check if we're on a Bloglo admin page.
 *
 * @since 1.0.0
 * @param boolean|string $base current screen base.
 * @param string         $slug page slug.
 * @return boolean
 */
function bloglo_is_admin_page( $base = false, $slug = 'bloglo' ) {

	if ( false === $base ) {
		$base = get_current_screen()->base;
	}

	return false !== strpos( $base, $slug );
}

/**
 * Print admin notice.
 *
 * @since 1.0.0
 * @param array $args array of options.
 * @return boolean|void
 */
function bloglo_print_notice( $args ) {

	$defaults = array(
		'type'           => 'success',
		'message'        => '',
		'is_dismissible' => true,
		'message_id'     => '',
		'expires'        => 0,
		'display_on'     => array(),
		'action_link'    => '',
		'action_text'    => '',
		'dismiss_text'   => esc_html__( 'Dismiss', 'bloglo' ),
	);

	$args = wp_parse_args( $args, $defaults );

	if ( bloglo_is_notice_dismissed( $args['message_id'] ) ) {
		return false;
	}

	if ( ! empty( $args['display_on'] ) ) {

		$base    = get_current_screen()->base;
		$display = false;

		foreach ( $args['display_on'] as $page ) {
			if ( false !== strpos( $base, $page ) ) {
				$display = true;
			}
		}

		if ( ! $display ) {
			return false;
		}
	}

	$bloglo_is_dismissible = $args['is_dismissible'] ? ' is-dismissible' : ''; ?>

	<div id="<?php echo esc_attr( $args['message_id'] ); ?>" class="notice bloglo-notice notice-<?php echo esc_attr( $args['type'] ); ?><?php echo esc_attr( $bloglo_is_dismissible ); ?>">
		<p><?php echo ( wp_kses( $args['message'], bloglo_get_allowed_html_tags() ) ); ?></p>

		<?php
		if ( $args['action_link'] && $args['action_text'] ) {
			?>
			<p class="bloglo-notice-action">
				<a href="<?php echo esc_url( $args['action_link'] ); ?>" class="bloglo-btn primary button button-primary" role="button"><?php echo esc_html( $args['action_text'] ); ?></a>

				<?php
				if ( $args['dismiss_text'] ) {
					?>
					<a href="#" class="bloglo-btn secondary button button-secondary bloglo-notice-dismiss" role="button"><?php echo esc_html( $args['dismiss_text'] ); ?></a>
					<?php
				}
				?>
			</p><!-- END .bloglo-notice-action -->
			<?php
		}
		?>
	</div>

	<script type="text/javascript">
		jQuery( document ).ready( function ( $ ) {

			var msgid = "<?php echo esc_attr( $args['message_id'] ); ?>";
			var $el   = $( '#' + msgid );

			$el.on( 'click', '.notice-dismiss, .bloglo-notice-dismiss', function ( event ) {

				var expires = "<?php echo esc_attr( $args['expires'] ); ?>";
				var nonce = "<?php echo esc_attr( wp_create_nonce( 'bloglo_dismiss_notice' ) ); ?>";

				$.post( ajaxurl, {
					action: 		'bloglo_dismiss_notice',
					msgid: 			msgid,
					expires: 		expires,
					_ajax_nonce: 	nonce,
				} );

				$el.fadeTo( 100, 0, function() {
					$el.slideUp( 100, function() {
						$el.remove();
					});
				});
			} );
		} );
	</script>
	<?php
}

/**
 * Check if admin notice is dismissed.
 *
 * @since 1.0.0
 * @param array $id Notice ID.
 * @return boolean
 */
function bloglo_is_notice_dismissed( $id ) {

	if ( false !== get_transient( 'bloglo_notice_' . $id ) ) {
		return true;
	}

	return false;
}

/**
 * Ajax handler to dismiss admin notice.
 *
 * @since 1.0.0
 * @return void
 */
function bloglo_dismiss_notice() {

	check_ajax_referer( 'bloglo_dismiss_notice' );

	if ( ! isset( $_POST['msgid'] ) ) {
		die;
	}

	$message_id = sanitize_text_field( wp_unslash( $_POST['msgid'] ) );
	$expires    = isset( $post['expires'] ) ? intval( $post['expires'] ) : 0;

	$message              = (array) get_transient( 'bloglo_notice_' . $message_id );
	$message['time']      = time();
	$message['dismissed'] = true;

	set_transient( 'bloglo_notice_' . $message_id, $message, $expires );
	die;
}
add_action( 'wp_ajax_bloglo_dismiss_notice', 'bloglo_dismiss_notice' );

/**
 * Print admin icon.
 *
 * @since 1.0.0
 * @param string $icon             Icon name.
 * @param string $tooltip          Tooltip text.
 * @param string $tooltip_position Position of the tooltip.
 * @return void
 */
function bloglo_print_admin_icon( $icon = 'info', $tooltip = '', $tooltip_position = 'right-tooltip' ) {

	$svg_icon = '<svg width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 9h-2V7h2v2zm0 2h-2v6h2v-6zm-1-7c-4.41 0-8 3.59-8 8s3.59 8 8 8 8-3.59 8-8-3.59-8-8-8m0-2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2z"/></svg>';

	if ( '' !== $tooltip ) {
		$tooltip = '<span class="bloglo-tooltip ' . esc_attr( $tooltip_position ) . '">' . esc_html( $tooltip ) . '</span>';
	}

	if ( 'warning' === $icon ) {
		echo '<i class="bloglo-warning-icon">' . $svg_icon . $tooltip . '</i>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	} elseif ( 'info' === $icon ) {
		echo '<i class="bloglo-info-icon">' . $svg_icon . $tooltip . '</i>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	}
}

/**
 * Check if currently using block editor page.
 *
 * @since 1.0.0
 * @return boolean
 */
function bloglo_is_block_editor() {

	if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
		// The Gutenberg plugin is on.
		return true;
	}

	$current_screen = get_current_screen();
	if ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() ) {
		// Gutenberg page on 5+.
		return true;
	}

	return false;
}

/**
 * Print help icon with a link to documentation.
 *
 * @param  array $args Optional parameters.
 * @param  bool  $echo Return or print the link.
 * @since  1.0.0
 * @return void|string
 */
function bloglo_help_link( $args = array(), $echo = true ) {

	if ( ! apply_filters( 'bloglo_display_help_links', true ) ) {
		return;
	}

	$defaults = array(
		'link'  => '',
		'class' => array(),
	);

	$args = wp_parse_args( $args, $defaults );

	$args['class']   = (array) $args['class'];
	$args['class'][] = 'bloglo-help-link';

	$class = trim( implode( ' ', $args['class'] ) );

	$icon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"/></svg>';

	$output = sprintf(
		'<a href="%1$s" rel="nofollow" target="_blank" class="%2$s"><span class="bloglo-help-icon">%4$s</span>%3$s</a>',
		esc_url( $args['link'] ),
		esc_attr( $class ),
		esc_html__( 'How to use', 'bloglo' ),
		$icon
	);

	if ( $echo ) {
		echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	} else {
		return $output;
	}
}
index.php000064400000000225152425717710006376 0ustar00<?php
/**
 * Index file
 *
 * @package     Bloglo
 * @author      Peregrine Themes
 * @since       1.0.0
 */

/* Silence is golden, and we agree. */
class-bloglo-admin.php000064400000022517152425717710010746 0ustar00<?php
/**
 * Admin class.
 *
 * This class ties together all admin classes.
 *
 * @package     Bloglo
 * @author      Peregrine Themes
 * @since       1.0.0
 */

/**
 * Do not allow direct script access.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Bloglo_Admin' ) ) :

	/**
	 * Admin Class
	 */
	class Bloglo_Admin {

		/**
		 * Primary class constructor.
		 *
		 * @since 1.0.0
		 */
		public function __construct() {

			/**
			 * Include admin files.
			 */
			$this->includes();

			/**
			 * Load admin assets.
			 */
			add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );

			/**
			 * Add filters for WordPress header and footer text.
			 */
			add_filter( 'update_footer', array( $this, 'filter_update_footer' ), 50 );
			add_filter( 'admin_footer_text', array( $this, 'filter_admin_footer_text' ), 50 );

			/**
			 * Admin page header.
			 */
			add_action( 'in_admin_header', array( $this, 'admin_header' ), 100 );

			/**
			 * Admin page footer.
			 */
			add_action( 'in_admin_footer', array( $this, 'admin_footer' ), 100 );

			/**
			 * Add notices.
			 */
			add_action( 'admin_notices', array( $this, 'admin_notices' ) );

			/**
			 * After admin loaded
			 */
			do_action( 'bloglo_admin_loaded' );
		}

		/**
		 * Includes files.
		 *
		 * @since 1.0.0
		 */
		private function includes() {

			/**
			 * Include helper functions.
			 */
			require_once BLOGLO_THEME_PATH . '/inc/admin/helpers.php'; // phpcs:ignore

			/**
			 * Include Bloglo welcome page.
			 */
			require_once BLOGLO_THEME_PATH . '/inc/admin/class-bloglo-dashboard.php'; // phpcs:ignore

			/**
			 * Guten block
			 */
			// require_once BLOGLO_THEME_PATH . '/inc/admin/guten-block.php'; // phpcs:ignore

			/**
			 * Include Bloglo meta boxes.
			 */
			require_once BLOGLO_THEME_PATH . '/inc/admin/metabox/class-bloglo-meta-boxes.php'; // phpcs:ignore

		}

		/**
		 * Load our required assets on admin pages.
		 *
		 * @since 1.0.0
		 * @param string $hook it holds the information about the current page.
		 */
		public function load_assets( $hook ) {
			/**
			 * Do not enqueue if we are not on one of our pages.
			 */
			if ( ! bloglo_is_admin_page( $hook ) ) {
				return;
			}

			// Script debug.
			$prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'dev/' : '';
			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

			/**
			 * Enqueue admin pages stylesheet.
			 */
			wp_enqueue_style(
				'bloglo-admin-styles',
				BLOGLO_THEME_URI . '/inc/admin/assets/css/bloglo-admin' . $suffix . '.css',
				false,
				BLOGLO_THEME_VERSION
			);

			/**
			 * Enqueue admin pages script.
			 */
			wp_enqueue_script(
				'bloglo-admin-script',
				BLOGLO_THEME_URI . '/inc/admin/assets/js/' . $prefix . 'bloglo-admin' . $suffix . '.js',
				array( 'jquery', 'wp-util', 'updates' ),
				BLOGLO_THEME_VERSION,
				true
			);

			/**
			 * Localize admin strings.
			 */
			$texts = array(
				'install'               => esc_html__( 'Install', 'bloglo' ),
				'install-inprogress'    => esc_html__( 'Installing...', 'bloglo' ),
				'activate-inprogress'   => esc_html__( 'Activating...', 'bloglo' ),
				'deactivate-inprogress' => esc_html__( 'Deactivating...', 'bloglo' ),
				'active'                => esc_html__( 'Active', 'bloglo' ),
				'retry'                 => esc_html__( 'Retry', 'bloglo' ),
				'please_wait'           => esc_html__( 'Please Wait...', 'bloglo' ),
				'importing'             => esc_html__( 'Importing... Please Wait...', 'bloglo' ),
				'currently_processing'  => esc_html__( 'Currently processing: ', 'bloglo' ),
				'import'                => esc_html__( 'Import', 'bloglo' ),
				'import_demo'           => esc_html__( 'Import Demo', 'bloglo' ),
				'importing_notice'      => esc_html__( 'The demo importer is still working. Closing this window may result in failed import.', 'bloglo' ),
				'import_complete'       => esc_html__( 'Import Complete!', 'bloglo' ),
				'import_complete_desc'  => esc_html__( 'The demo has been imported.', 'bloglo' ) . ' <a href="' . esc_url( get_home_url() ) . '">' . esc_html__( 'Visit site.', 'bloglo' ) . '</a>',
			);

			$strings = array(
				'ajaxurl'       => admin_url( 'admin-ajax.php' ),
				'wpnonce'       => wp_create_nonce( 'bloglo_nonce' ),
				'texts'         => $texts,
				'color_pallete' => array( '#0554f2', '#06cca6', '#2c2e3a', '#e4e7ec', '#f0b849', '#ffffff', '#000000' ),
			);

			$strings = apply_filters( 'bloglo_admin_strings', $strings );

			wp_localize_script( 'bloglo-admin-script', 'hester_strings', $strings );
		}

		/**
		 * Filters WordPress footer right text to hide all text.
		 *
		 * @since 1.0.0
		 * @param string $text Text that we're going to replace.
		 */
		public function filter_update_footer( $text ) {

			$base = get_current_screen()->base;

			/**
			 * Only do this if we are on one of our plugin pages.
			 */
			if ( bloglo_is_admin_page( $base ) ) {
				return apply_filters( 'bloglo_footer_version', esc_html__( 'Bloglo Theme', 'bloglo' ) . ' ' . BLOGLO_THEME_VERSION . '<br/><a href="' . esc_url( 'https://twitter.com/peregrine-themes' ) . '" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-twitter"></span></a><a href="' . esc_url( 'https://www.facebook.com/peregrinethemes' ) . '" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-facebook"></span></a>' );
			} else {
				return $text;
			}
		}

		/**
		 * Filter WordPress footer left text to display our text.
		 *
		 * @since 1.0.0
		 * @param string $text Text that we're going to replace.
		 */
		public function filter_admin_footer_text( $text ) {

			if ( bloglo_is_admin_page() ) {
				return;
			}

			return $text;
		}

		/**
		 * Outputs the page admin header.
		 *
		 * @since 1.0.0
		 */
		public function admin_header() {

			$base = get_current_screen()->base;

			if ( ! bloglo_is_admin_page( $base ) ) {
				return;
			}
			?>

			<div id="hester-header">
				<div class="hester-container">

					<a href="<?php echo esc_url( admin_url( 'admin.php?page=bloglo-dashboard' ) ); ?>" class="hester-logo">
						<img src="<?php echo esc_url( BLOGLO_THEME_URI . '/assets/images/bloglo-logo.svg' ); ?>" alt="<?php echo esc_html( 'bloglo' ); ?>" />
					</a>

					<span class="hester-header-action">
						<a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>"><?php esc_html_e( 'Customize', 'bloglo' ); ?></a>
						<a href="<?php echo esc_url( 'http://docs.peregrine-themes.com/' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Help Articles', 'bloglo' ); ?></a>
					</span>

				</div>
			</div><!-- END #hester-header -->
			<?php
		}

		/**
		 * Outputs the page admin footer.
		 *
		 * @since 1.0.0
		 */
		public function admin_footer() {

			$base = get_current_screen()->base;

			if ( ! bloglo_is_admin_page( $base ) || bloglo_is_admin_page( $base, 'hester_wizard' ) ) {
				return;
			}
			?>
			<div id="hester-footer">
			<ul>
				<li><a href="<?php echo esc_url( 'http://docs.peregrine-themes.com/' ); ?>" target="_blank" rel="noopener noreferrer"><span><?php esc_html_e( 'Help Articles', 'bloglo' ); ?></span></span></a></li>
				<li><a href="<?php echo esc_url( 'https://www.facebook.com/peregrinethemes' ); ?>" target="_blank" rel="noopener noreferrer"><span><?php esc_html_e( 'Follow Facebook page', 'bloglo' ); ?></span></span></a></li>
				<li><a href="<?php echo esc_url( 'https://wordpress.org/support/theme/bloglo/reviews/#new-post' ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-heart" aria-hidden="true"></span><span><?php esc_html_e( 'Leave a Review', 'bloglo' ); ?></span></a></li>
			</ul>
			</div><!-- END #hester-footer -->

			<?php
		}

		/**
		 * Admin Notices
		 *
		 * @since 1.0.0
		 */
		public function admin_notices() {

			$screen = get_current_screen();

			// Display on Dashboard, Themes and Bloglo admin pages.
			if ( ! in_array( $screen->base, array( 'dashboard', 'themes' ), true ) && ! bloglo_is_admin_page() ) {
				return;
			}

			// Display if not dismissed and not on Bloglo plugins page.
			if ( ! bloglo_is_notice_dismissed( 'bloglo_notice_recommended-plugins' ) && ! bloglo_is_admin_page( false, 'bloglo-plugins' ) ) {

				$plugins = bloglo_plugin_utilities()->get_recommended_plugins();
				$plugins = bloglo_plugin_utilities()->get_deactivated_plugins( $plugins );

				$plugin_list = '';

				if ( is_array( $plugins ) && ! empty( $plugins ) ) {

					foreach ( $plugins as $slug => $plugin ) {

						$url = admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . esc_attr( $slug ) . '&TB_iframe=true&width=990&height=500' );

						$plugin_list .= '<a href="' . esc_url( $url ) . '" class="thickbox">' . esc_html( $plugin['name'] ) . '</a>, ';
					}

					wp_enqueue_script( 'plugin-install' );
					add_thickbox();

					$plugin_list = trim( $plugin_list, ', ' );

					/* translators: %1$s <strong> tag, %2$s </strong> tag */
					$message = sprintf( wp_kses( __( 'Bloglo theme recommends the following plugins: %1$s.', 'bloglo' ), bloglo_get_allowed_html_tags() ), $plugin_list );

					$navigation_items = bloglo_dashboard()->get_navigation_items();

					bloglo_print_notice(
						array(
							'type'        => 'info',
							'message'     => $message,
							'message_id'  => 'recommended-plugins',
							'expires'     => 7 * 24 * 60 * 60,
							'action_link' => $navigation_items['plugins']['url'],
							'action_text' => esc_html__( 'Install Now', 'bloglo' ),
						)
					);
				}
			}

		}
	}
endif;
class-bloglo-dashboard.php000064400000042226152425717710011604 0ustar00<?php
/**
 * Bloglo About page class.
 *
 * @package     Bloglo
 * @author      Peregrine Themes
 * @since       1.0.0
 */

/**
 * Do not allow direct script access.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Bloglo_Dashboard' ) ) :
	/**
	 * Bloglo Dashboard page class.
	 */
	final class Bloglo_Dashboard {

		/**
		 * Singleton instance of the class.
		 *
		 * @since 1.0.0
		 * @var object
		 */
		private static $instance;

		/**
		 * Main Bloglo Dashboard Instance.
		 *
		 * @since 1.0.0
		 * @return Bloglo_Dashboard
		 */
		public static function instance() {

			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bloglo_Dashboard ) ) {
				self::$instance = new self();
			}
			return self::$instance;
		}

		/**
		 * Primary class constructor.
		 *
		 * @since 1.0.0
		 */
		public function __construct() {

			/**
			 * Register admin menu item under Appearance menu item.
			 */
			add_action( 'admin_menu', array( $this, 'add_to_menu' ), 10 );
			add_filter( 'submenu_file', array( $this, 'highlight_submenu' ) );

			/**
			 * Ajax activate & deactivate plugins.
			 */
			add_action( 'wp_ajax_hester-plugin-activate', array( $this, 'activate_plugin' ) );
			add_action( 'wp_ajax_hester-plugin-deactivate', array( $this, 'deactivate_plugin' ) );
		}

		/**
		 * Register our custom admin menu item.
		 *
		 * @since 1.0.0
		 */
		public function add_to_menu() {

			/**
			 * Dashboard page.
			 */
			add_theme_page(
				esc_html__( 'Bloglo Theme', 'bloglo' ),
				'Bloglo Theme',
				apply_filters( 'bloglo_manage_cap', 'edit_theme_options' ),
				'bloglo-dashboard',
				array( $this, 'render_dashboard' )
			);

			/**
			 * Plugins page.
			 */
			add_theme_page(
				esc_html__( 'Plugins', 'bloglo' ),
				'Plugins',
				apply_filters( 'bloglo_manage_cap', 'edit_theme_options' ),
				'bloglo-plugins',
				array( $this, 'render_plugins' )
			);

			// Hide from admin navigation.
			remove_submenu_page( 'themes.php', 'bloglo-plugins' );

			/**
			 * Changelog page.
			 */
			add_theme_page(
				esc_html__( 'Changelog', 'bloglo' ),
				'Changelog',
				apply_filters( 'bloglo_manage_cap', 'edit_theme_options' ),
				'bloglo-changelog',
				array( $this, 'render_changelog' )
			);

			// Hide from admin navigation.
			remove_submenu_page( 'themes.php', 'bloglo-changelog' );
		}

		/**
		 * Render dashboard page.
		 *
		 * @since 1.0.0
		 */
		public function render_dashboard() {

			// Render dashboard navigation.
			$this->render_navigation();

			?>
			<div class="hester-container">

				<div class="hester-section-title">
					<h2 class="hester-section-title"><?php esc_html_e( 'Getting Started', 'bloglo' ); ?></h2>
				</div><!-- END .hester-section-title -->

				<div class="hester-section hester-columns">

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-admin-plugins"></i><?php esc_html_e( 'Install Plugins', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Explore recommended plugins. These free plugins provide additional features and customization options.', 'bloglo' ); ?></p>

							<div class="hester-buttons">
								<a href="<?php echo esc_url( menu_page_url( 'bloglo-plugins', false ) ); ?>" class="hester-btn secondary" role="button"><?php esc_html_e( 'Install Plugins', 'bloglo' ); ?></a>
							</div><!-- END .hester-buttons -->
						</div>
					</div>

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-layout"></i><?php esc_html_e( 'Start with a Template', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Don&rsquo;t want to start from scratch? Import a pre-built demo website in 1-click and get a head start.', 'bloglo' ); ?></p>

							<div class="hester-buttons plugins">

								<?php
								if ( file_exists( WP_PLUGIN_DIR . '/hester-core/hester-core.php' ) && is_plugin_inactive( 'hester-core/hester-core.php' ) ) {
									$class       = 'hester-btn secondary';
									$button_text = __( 'Activate Hester Core', 'bloglo' );
									$link        = '#';
									$data        = ' data-plugin="hester-core" data-action="activate" data-redirect="' . esc_url( admin_url( 'admin.php?page=bloglo-demo-library' ) ) . '"';
								} elseif ( ! file_exists( WP_PLUGIN_DIR . '/hester-core/hester-core.php' ) ) {
									$class       = 'hester-btn secondary';
									$button_text = __( 'Install Hester Core', 'bloglo' );
									$link        = '#';
									$data        = ' data-plugin="hester-core" data-action="install" data-redirect="' . esc_url( admin_url( 'admin.php?page=bloglo-demo-library' ) ) . '"';
								} else {
									$class       = 'hester-btn secondary active';
									$button_text = __( 'Browse Demos', 'bloglo' );
									$link        = admin_url( 'admin.php?page=bloglo-demo-library' );
									$data        = '';
								}

								printf(
									'<a class="%1$s" %2$s %3$s role="button"> %4$s </a>',
									esc_attr( $class ),
									isset( $link ) ? 'href="' . esc_url( $link ) . '"' : '',
									$data, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
									esc_html( $button_text )
								);
								?>

							</div><!-- END .hester-buttons -->
						</div>
					</div>

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-palmtree"></i><?php esc_html_e( 'Upload Your Logo', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Kick off branding your new site by uploading your logo. Simply upload your logo and customize as you need.', 'bloglo' ); ?></p>

							<div class="hester-buttons">
								<a href="<?php echo esc_url( admin_url( 'customize.php?autofocus[control]=custom_logo' ) ); ?>" class="hester-btn secondary" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Upload Logo', 'bloglo' ); ?></a>
							</div><!-- END .hester-buttons -->
						</div>
					</div>

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-welcome-widgets-menus"></i><?php esc_html_e( 'Change Menus', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Customize menu links and choose what&rsquo;s displayed in available theme menu locations.', 'bloglo' ); ?></p>

							<div class="hester-buttons">
								<a href="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>" class="hester-btn secondary" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Go to Menus', 'bloglo' ); ?></a>
							</div><!-- END .hester-buttons -->
						</div>
					</div>

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-art"></i><?php esc_html_e( 'Change Colors', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Replace the default theme colors and make your website color scheme match your brand design.', 'bloglo' ); ?></p>

							<div class="hester-buttons">
								<a href="<?php echo esc_url( admin_url( 'customize.php?autofocus[section]=bloglo_section_colors' ) ); ?>" class="hester-btn secondary" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Change Colors', 'bloglo' ); ?></a>
							</div><!-- END .hester-buttons -->
						</div>
					</div>

					<div class="hester-column">
						<div class="hester-box">
							<h4><i class="dashicons dashicons-editor-help"></i><?php esc_html_e( 'Need Help?', 'bloglo' ); ?></h4>
							<p><?php esc_html_e( 'Head over to our site to learn more about the Bloglo theme, read help articles and get support.', 'bloglo' ); ?></p>

							<div class="hester-buttons">
								<a href="http://docs.peregrine-themes.com/" target="_blank" rel="noopener noreferrer" class="hester-btn secondary"><?php esc_html_e( 'Help Articles', 'bloglo' ); ?></a>
							</div><!-- END .hester-buttons -->
						</div>
					</div>
				</div><!-- END .hester-section -->

				<div class="hester-section large-section">
					<div class="hester-hero">
						<img src="<?php echo esc_url( BLOGLO_THEME_URI . '/assets/images/bloglo-customize.svg' ); ?>" alt="<?php echo esc_html( 'Customize' ); ?>" />
					</div>

					<h2><?php esc_html_e( 'Let‘s customize your website', 'bloglo' ); ?></h2>
					<p><?php esc_html_e( 'There are many changes you can make to customize your website. Explore Bloglo customization options and make it unique.', 'bloglo' ); ?></p>

					<div class="hester-buttons">
						<a href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>" class="hester-btn primary large-button"><?php esc_html_e( 'Start Customizing', 'bloglo' ); ?></a>
					</div><!-- END .hester-buttons -->

				</div><!-- END .hester-section -->

				<?php do_action( 'bloglo_about_content_after' ); ?>

			</div><!-- END .hester-container -->

			<?php
		}

		/**
		 * Render the recommended plugins page.
		 *
		 * @since 1.0.0
		 */
		public function render_plugins() {

			// Render dashboard navigation.
			$this->render_navigation();

			$plugins = bloglo_plugin_utilities()->get_recommended_plugins();
			?>
			<div class="hester-container">

				<div class="hester-section-title">
					<h2 class="hester-section-title"><?php esc_html_e( 'Recommended Plugins', 'bloglo' ); ?></h2>
				</div><!-- END .hester-section-title -->

				<div class="hester-section hester-columns plugins">

					<?php if ( is_array( $plugins ) && ! empty( $plugins ) ) { ?>
						<?php foreach ( $plugins as $plugin ) { ?>

							<?php
							// Check plugin status.
							if ( bloglo_plugin_utilities()->is_activated( $plugin['slug'] ) ) {
								$btn_class = 'hester-btn secondary';
								$btn_text  = esc_html__( 'Deactivate', 'bloglo' );
								$action    = 'deactivate';
								$notice    = '<span class="hester-active-plugin"><span class="dashicons dashicons-yes"></span>' . esc_html__( 'Plugin activated', 'bloglo' ) . '</span>';
							} elseif ( bloglo_plugin_utilities()->is_installed( $plugin['slug'] ) ) {
								$btn_class = 'hester-btn primary';
								$btn_text  = esc_html__( 'Activate', 'bloglo' );
								$action    = 'activate';
								$notice    = '';
							} else {
								$btn_class = 'hester-btn primary';
								$btn_text  = esc_html__( 'Install & Activate', 'bloglo' );
								$action    = 'install';
								$notice    = '';
							}
							?>

							<div class="hester-column column-6">
								<div class="hester-box">

									<div class="plugin-image">
										<img src="<?php echo esc_url( $plugin['thumb'] ); ?>" alt="<?php echo esc_html( $plugin['name'] ); ?>"/>					
									</div>

									<div class="plugin-info">
										<h4><?php echo esc_html( $plugin['name'] ); ?></h4>
										<p><?php echo esc_html( $plugin['desc'] ); ?></p>
										<div class="hester-buttons">
											<?php echo ( wp_kses_post( $notice ) ); ?>
											<a href="#" class="<?php echo esc_attr( $btn_class ); ?>" data-plugin="<?php echo esc_attr( $plugin['slug'] ); ?>" data-action="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $btn_text ); ?></a>
										</div>
									</div>

								</div>
							</div>
						<?php } ?>
					<?php } ?>

				</div><!-- END .hester-section -->

				<?php do_action( 'bloglo_recommended_plugins_after' ); ?>

			</div><!-- END .hester-container -->

			<?php
		}

		/**
		 * Render the changelog page.
		 *
		 * @since 1.0.0
		 */
		public function render_changelog() {

			// Render dashboard navigation.
			$this->render_navigation();

			$changelog = BLOGLO_THEME_PATH . '/changelog.txt';

			if ( ! file_exists( $changelog ) ) {
				$changelog = esc_html__( 'Changelog file not found.', 'bloglo' );
			} elseif ( ! is_readable( $changelog ) ) {
				$changelog = esc_html__( 'Changelog file not readable.', 'bloglo' );
			} else {
				global $wp_filesystem;

				// Check if the the global filesystem isn't setup yet.
				if ( is_null( $wp_filesystem ) ) {
					WP_Filesystem();
				}

				$changelog = $wp_filesystem->get_contents( $changelog );
			}

			?>
			<div class="hester-container">

				<div class="hester-section-title">
					<h2 class="hester-section-title">
						<span><?php esc_html_e( 'Bloglo Theme Changelog', 'bloglo' ); ?></span>
						<span class="changelog-version"><?php echo esc_html( sprintf( 'v%1$s', BLOGLO_THEME_VERSION ) ); ?></span>
					</h2>

				</div><!-- END .hester-section-title -->

				<div class="hester-section hester-columns">

					<div class="hester-column column-12">
						<div class="hester-box hester-changelog">
							<pre><?php echo esc_html( $changelog ); ?></pre>
						</div>
					</div>
				</div><!-- END .hester-columns -->

				<?php do_action( 'bloglo_after_changelog' ); ?>

			</div><!-- END .hester-container -->
			<?php
		}

		/**
		 * Render admin page navigation tabs.
		 *
		 * @since 1.0.0
		 */
		public function render_navigation() {

			// Get navigation items.
			$menu_items = $this->get_navigation_items();

			?>
			<div class="hester-container">

				<div class="hester-tabs">
					<ul>
						<?php
						// Determine current tab.
						$base = $this->get_current_page();

						// Display menu items.
						foreach ( $menu_items as $item ) {

							// Check if we're on a current item.
							$current = false !== strpos( $base, $item['id'] ) ? 'current-item' : '';
							?>

							<li class="<?php echo esc_attr( $current ); ?>">
								<a href="<?php echo esc_url( $item['url'] ); ?>">
									<?php echo esc_html( $item['name'] ); ?>

									<?php
									if ( isset( $item['icon'] ) && $item['icon'] ) {
										bloglo_print_admin_icon( $item['icon'] );
									}
									?>
								</a>
							</li>

						<?php } ?>
					</ul>
				</div><!-- END .hester-tabs -->

			</div><!-- END .hester-container -->
			<?php
		}

		/**
		 * Return the current Bloglo Dashboard page.
		 *
		 * @since 1.0.0
		 * @return string $page Current dashboard page slug.
		 */
		public function get_current_page() {

			$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : 'dashboard'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
			$page = str_replace( 'bloglo-', '', $page );
			$page = apply_filters( 'bloglo_dashboard_current_page', $page );

			return esc_html( $page );
		}

		/**
		 * Print admin page navigation items.
		 *
		 * @since 1.0.0
		 * @return array $items Array of navigation items.
		 */
		public function get_navigation_items() {

			$items = array(
				'dashboard' => array(
					'id'   => 'dashboard',
					'name' => esc_html__( 'About', 'bloglo' ),
					'icon' => '',
					'url'  => menu_page_url( 'bloglo-dashboard', false ),
				),
				'plugins'   => array(
					'id'   => 'plugins',
					'name' => esc_html__( 'Recommended Plugins', 'bloglo' ),
					'icon' => '',
					'url'  => menu_page_url( 'bloglo-plugins', false ),
				),
				'changelog' => array(
					'id'   => 'changelog',
					'name' => esc_html__( 'Changelog', 'bloglo' ),
					'icon' => '',
					'url'  => menu_page_url( 'bloglo-changelog', false ),
				),
			);

			return apply_filters( 'bloglo_dashboard_navigation_items', $items );
		}

		/**
		 * Activate plugin.
		 *
		 * @since 1.0.0
		 */
		public function activate_plugin() {

			// Security check.
			check_ajax_referer( 'bloglo_nonce' );

			// Plugin data.
			$plugin = isset( $_POST['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) : '';

			if ( empty( $plugin ) ) {
				wp_send_json_error( esc_html__( 'Missing plugin data', 'bloglo' ) );
			}

			if ( $plugin ) {

				$response = bloglo_plugin_utilities()->activate_plugin( $plugin );

				if ( is_wp_error( $response ) ) {
					wp_send_json_error( $response->get_error_message(), $response->get_error_code() );
				}

				wp_send_json_success();
			}

			wp_send_json_error( esc_html__( 'Failed to activate plugin. Missing plugin data.', 'bloglo' ) );
		}

		/**
		 * Deactivate plugin.
		 *
		 * @since 1.0.0
		 */
		public function deactivate_plugin() {

			// Security check.
			check_ajax_referer( 'bloglo_nonce' );

			// Plugin data.
			$plugin = isset( $_POST['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) : '';

			if ( empty( $plugin ) ) {
				wp_send_json_error( esc_html__( 'Missing plugin data', 'bloglo' ) );
			}

			if ( $plugin ) {
				$response = bloglo_plugin_utilities()->deactivate_plugin( $plugin );

				if ( is_wp_error( $response ) ) {
					wp_send_json_error( $response->get_error_message(), $response->get_error_code() );
				}

				wp_send_json_success();
			}

			wp_send_json_error( esc_html__( 'Failed to deactivate plugin. Missing plugin data.', 'bloglo' ) );
		}

		/**
		 * Highlight dashboard page for plugins page.
		 *
		 * @since 1.0.0
		 * @param string $submenu_file The submenu file.
		 */
		public function highlight_submenu( $submenu_file ) {

			global $pagenow;

			// Check if we're on bloglo plugins or changelog page.
			if ( 'themes.php' === $pagenow ) {
				if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
					if ( 'bloglo-plugins' === $_GET['page'] || 'bloglo-changelog' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
						$submenu_file = 'bloglo-dashboard';
					}
				}
			}

			return $submenu_file;
		}
	}
endif;

/**
 * The function which returns the one Bloglo_Dashboard instance.
 *
 * Use this function like you would a global variable, except without needing
 * to declare the global.
 *
 * Example: <?php $bloglo_dashboard = bloglo_dashboard(); ?>
 *
 * @since 1.0.0
 * @return object
 */
function bloglo_dashboard() {
	return Bloglo_Dashboard::instance();
}

bloglo_dashboard();
meta-box-post-layout.php000060400000011251152435123320011263 0ustar00<?php
/**
 * Adds the layout meta box to the post editing screen for post types that support `theme-layouts`.
 *
 * @package    HybridCore
 * @subpackage Admin
 * @author     Justin Tadlock <justin@justintadlock.com>
 * @copyright  Copyright (c) 2008 - 2015, Justin Tadlock
 * @link       http://themehybrid.com/hybrid-core
 * @license    http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

# Add the layout meta box on the 'add_meta_boxes' hook.
add_action( 'add_meta_boxes', 'hybrid_add_post_layout_meta_box', 10, 2 );

# Saves the post layout on the post editing page.
add_action( 'save_post',       'hybrid_save_post_layout', 10, 2 );
add_action( 'add_attachment',  'hybrid_save_post_layout'        );
add_action( 'edit_attachment', 'hybrid_save_post_layout'        );

/**
 * Adds the layout meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  string  $post_type
 * @param  object  $post
 * @return void
 */
function hybrid_add_post_layout_meta_box( $post_type ) {

	if ( current_theme_supports( 'theme-layouts', 'post_meta' ) && post_type_supports( $post_type, 'theme-layouts' ) && current_user_can( 'edit_theme_options' ) ) {

		// Add meta box.
		add_meta_box( 'hybrid-post-layout', esc_html__( 'Layout', 'hybrid-core' ), 'hybrid_post_layout_meta_box', $post_type, 'side', 'default' );

		// Load scripts/styles.
		add_action( 'admin_enqueue_scripts', 'hybrid_post_layout_enqueue', 5 );
	}
}

/**
 * Loads the scripts/styles for the layout meta box.
 *
 * @since  3.0.0
 * @access public
 * @return void
 */
function hybrid_post_layout_enqueue() {
	wp_enqueue_style( 'hybrid-admin' );
}

/**
 * Callback function for displaying the layout meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  object  $object
 * @param  array   $box
 * @return void
 */
function hybrid_post_layout_meta_box( $post, $box ) {

	// Get the current post's layout.
	$post_layout = hybrid_get_post_layout( $post->ID );

	$post_layout = $post_layout ? $post_layout : 'default';

	wp_nonce_field( basename( __FILE__ ), 'hybrid-post-layout-nonce' ); ?>

	<?php foreach ( hybrid_get_layouts() as $layout ) : ?>

		<?php if ( true === $layout->is_post_layout && $layout->image && ! ( ! empty( $layout->post_types ) && ! in_array( $post->post_type, $layout->post_types ) ) ) : ?>

			<label class="has-img">
				<input type="radio" value="<?php echo esc_attr( $layout->name ); ?>" name="hybrid-post-layout" <?php checked( $post_layout, $layout->name ); ?> />

				<span class="screen-reader-text"><?php echo esc_html( $layout->label ); ?></span>

				<img src="<?php echo esc_url( sprintf( $layout->image, get_template_directory_uri(), get_stylesheet_directory_uri() ) ); ?>" alt="<?php echo esc_attr( $layout->label ); ?>" />
			</label>

		<?php endif; ?>

	<?php endforeach; ?>

	<script type="text/javascript">
	jQuery( document ).ready( function( $ ) {

		// Add the `.checked` class to whichever radio is checked.
		$( '#hybrid-post-layout input:checked' ).addClass( 'checked' );

		// When a radio is clicked.
		$( "#hybrid-post-layout input" ).click( function() {

			// If the radio has the `.checked` class, remove it and uncheck the radio.
			if ( $( this ).hasClass( 'checked' ) ) {

				$( "#hybrid-post-layout input" ).removeClass( 'checked' );
				$( this ).prop( 'checked', false );

			// If the radio is not checked, add the `.checked` class and check it.
			} else {

				$( "#hybrid-post-layout input" ).removeClass( 'checked' );
				$( this ).addClass( 'checked' );
			}
		} );
	} );
	</script>
<?php
}

/**
 * Saves the post layout when submitted via the layout meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  int      $post_id The ID of the current post being saved.
 * @param  object   $post    The post object currently being saved.
 * @return void|int
 */
function hybrid_save_post_layout( $post_id, $post = '' ) {

	// Fix for attachment save issue in WordPress 3.5. @link http://core.trac.wordpress.org/ticket/21963
	if ( ! is_object( $post ) )
		$post = get_post();

	// Verify the nonce for the post formats meta box.
	if ( ! isset( $_POST['hybrid-post-layout-nonce'] ) || ! wp_verify_nonce( $_POST['hybrid-post-layout-nonce'], basename( __FILE__ ) ) )
		return $post_id;

	// Get the previous post layout.
	$meta_value = hybrid_get_post_layout( $post_id );

	// Get the submitted post layout.
	$new_meta_value = isset( $_POST['hybrid-post-layout'] ) ? sanitize_key( $_POST['hybrid-post-layout'] ) : '';

	// If there is no new meta value but an old value exists, delete it.
	if ( '' == $new_meta_value && $meta_value )
		hybrid_delete_post_layout( $post_id );

	// If a new meta value was added and there was no previous value, add it.
	elseif ( $meta_value !== $new_meta_value )
		hybrid_set_post_layout( $post_id, $new_meta_value );
}
meta-box-post-style.php000060400000006132152435123320011110 0ustar00<?php
/**
 * Adds the post style meta box to the edit post screen.
 *
 * @package    HybridCore
 * @subpackage Admin
 * @author     Justin Tadlock <justin@justintadlock.com>
 * @copyright  Copyright (c) 2008 - 2015, Justin Tadlock
 * @link       http://themehybrid.com/hybrid-core
 * @license    http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

# Add the post stylesheets meta box on the 'add_meta_boxes' hook.
add_action( 'add_meta_boxes', 'hybrid_add_post_style_meta_box', 10, 2 );

# Saves the post meta box data.
add_action( 'save_post',       'hybrid_save_post_style', 10, 2 );
add_action( 'add_attachment',  'hybrid_save_post_style'        );
add_action( 'edit_attachment', 'hybrid_save_post_style'        );

/**
 * Adds the style meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  string  $post_type
 * @param  object  $post
 * @return void
 */
function hybrid_add_post_style_meta_box( $post_type, $post ) {

	$styles = hybrid_get_post_styles( $post_type );

	if ( ! empty( $styles ) && current_user_can( 'edit_theme_options' ) )
		add_meta_box( 'hybrid-post-style', esc_html__( 'Style', 'hybrid-core' ), 'hybrid_post_style_meta_box', $post_type, 'side', 'default' );
}

/**
 * Callback function for displaying the style meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  object  $object
 * @param  array   $box
 * @return void
 */
function hybrid_post_style_meta_box( $post, $box ) {

	$styles     = hybrid_get_post_styles( $post->post_type );
	$post_style = hybrid_get_post_style( $post->ID );

	wp_nonce_field( basename( __FILE__ ), 'hybrid-post-style-nonce' ); ?>

	<p>
		<select name="hybrid-post-style" class="widefat">

			<option value=""></option>

			<?php foreach ( $styles as $label => $file ) : ?>
				<option value="<?php echo esc_attr( $file ); ?>" <?php selected( $post_style, $file ); ?>><?php echo esc_html( $label ); ?></option>
			<?php endforeach; ?>

		</select>
	</p>
<?php }

/**
 * Saves the post style when submitted via the style meta box.
 *
 * @since  3.0.0
 * @access public
 * @param  int      $post_id The ID of the current post being saved.
 * @param  object   $post    The post object currently being saved.
 * @return void|int
 */
function hybrid_save_post_style( $post_id, $post = '' ) {

	// Fix for attachment save issue in WordPress 3.5. @link http://core.trac.wordpress.org/ticket/21963
	if ( ! is_object( $post ) )
		$post = get_post();

	// Verify the nonce before proceeding.
	if ( ! isset( $_POST['hybrid-post-style-nonce'] ) || ! wp_verify_nonce( $_POST['hybrid-post-style-nonce'], basename( __FILE__ ) ) )
		return;

	// Get the previous post style.
	$meta_value = hybrid_get_post_style( $post_id );

	// Get the submitted post style.
	$new_meta_value = isset( $_POST['hybrid-post-style'] ) ? sanitize_text_field( $_POST['hybrid-post-style'] ) : '';

	// If there is no new meta value but an old value exists, delete it.
	if ( '' == $new_meta_value && $meta_value )
		hybrid_delete_post_style( $post_id );

	// If a new meta value was added and there was no previous value, add it.
	elseif ( $meta_value !== $new_meta_value )
		hybrid_set_post_style( $post_id, $new_meta_value );
}
admin.php000060400000013557152435123320006354 0ustar00<?php
/**
 * Theme administration functions used with other components of the framework admin.  This file is for
 * setting up any basic features and holding additional admin helper functions.
 *
 * @package    HybridCore
 * @subpackage Admin
 * @author     Justin Tadlock <justin@justintadlock.com>
 * @copyright  Copyright (c) 2008 - 2015, Justin Tadlock
 * @link       http://themehybrid.com/hybrid-core
 * @license    http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

# Load the post meta boxes on the new post and edit post screens.
add_action( 'load-post.php',     'hybrid_admin_load_post_meta_boxes' );
add_action( 'load-post-new.php', 'hybrid_admin_load_post_meta_boxes' );

# Register scripts and styles.
add_action( 'admin_enqueue_scripts', 'hybrid_admin_register_styles',  0 );

# Allow posts page to be edited.
add_action( 'edit_form_after_title', 'hybrid_enable_posts_page_editor', 0 );

/**
 * Loads the core post meta box files on the 'load-post.php' action hook.  Each meta box file is only loaded if
 * the theme declares support for the feature.
 *
 * @since  1.2.0
 * @access public
 * @return void
 */
function hybrid_admin_load_post_meta_boxes() {

	// Load the post template meta box.
	require_if_theme_supports( 'hybrid-core-template-hierarchy', HYBRID_ADMIN . 'meta-box-post-template.php' );

	// Load the layout meta box.
	require_if_theme_supports( 'theme-layouts', HYBRID_ADMIN . 'meta-box-post-layout.php' );

	// Load the post style meta box.
	require_once( HYBRID_ADMIN . 'meta-box-post-style.php' );
}

/**
 * Registers admin styles.
 *
 * @since  3.0.0
 * @access public
 * @return void
 */
function hybrid_admin_register_styles() {
	wp_register_style( 'hybrid-admin', HYBRID_CSS . 'admin.css' );
}

/**
 * Fix for users who want to display content on the posts page above the posts list, which is a
 * theme feature common to themes built from the framework.
 *
 * @since  3.0.0
 * @access public
 * @param  object  $post
 * @return void
 */
function hybrid_enable_posts_page_editor( $post ) {

	if ( get_option( 'page_for_posts' ) != $post->ID )
		return;

	remove_action( 'edit_form_after_title', '_wp_posts_page_notice' );
	add_post_type_support( $post->post_type, 'editor' );
}

/**
 * Function for getting an array of available custom templates with a specific header. Ideally, this function
 * would be used to grab custom singular post (any post type) templates.  It is a recreation of the WordPress
 * page templates function because it doesn't allow for other types of templates.
 *
 * @since  0.7.0
 * @access public
 * @global object $hybrid
 * @param  string $post_type      The name of the post type to get templates for.
 * @return array  $post_templates The array of templates.
 */
function hybrid_get_post_templates( $post_type = 'post' ) {
	global $hybrid;

	// If templates have already been called, just return them.
	if ( ! empty( $hybrid->post_templates ) && isset( $hybrid->post_templates[ $post_type ] ) )
		return $hybrid->post_templates[ $post_type ];

	// Set up an empty array to house the templates.
	$post_templates = array();

	// Get the theme PHP files one level deep.
	$files = wp_get_theme( get_template() )->get_files( 'php', 1 );

	// If a child theme is active, get its files and merge with the parent theme files.
	if ( is_child_theme() )
		$files = array_merge( $files, wp_get_theme()->get_files( 'php', 1 ) );

	// Loop through each of the PHP files and check if they are post templates.
	foreach ( $files as $file => $path ) {

		// Get file data based on the post type singular name (e.g., "Post Template", "Book Template", etc.).
		$headers = get_file_data( $path, array( "{$post_type} Template" => "{$post_type} Template" ) );

		// Add the PHP filename and template name to the array.
		if ( ! empty( $headers["{$post_type} Template"] ) )
			$post_templates[ $file ] = $headers["{$post_type} Template"];
	}

	// Add the templates to the global $hybrid object.
	$hybrid->post_templates[ $post_type ] = array_flip( $post_templates );

	// Return array of post templates.
	return $hybrid->post_templates[ $post_type ];
}

/**
 * Gets the stylesheet files within the parent or child theme and checks if they have the 'Style Name'
 * header. If any files are found, they are returned in an array.
 *
 * @since  3.0.0
 * @access public
 * @global object  $hybrid
 * @return array
 */
function hybrid_get_post_styles( $post_type = 'post' ) {
	global $hybrid;

	// If stylesheets have already been loaded, return them.
	if ( ! empty( $hybrid->post_styles ) && isset( $hybrid->post_styles[ $post_type ] ) )
		return $hybrid->post_styles[ $post_type ];

	// Set up an empty styles array.
	$hybrid->post_styles[ $post_type ] = array();

	// Get the theme CSS files two levels deep.
	$files = wp_get_theme( get_template() )->get_files( 'css', 2 );

	// If a child theme is active, get its files and merge with the parent theme files.
	if ( is_child_theme() )
		$files = array_merge( $files, wp_get_theme()->get_files( 'css', 2 ) );

	// Loop through each of the CSS files and check if they are styles.
	foreach ( $files as $file => $path ) {

		// Get file data based on the 'Style Name' header.
		$headers = get_file_data(
			$path,
			array(
				'Style Name'         => 'Style Name',
				"{$post_type} Style" => "{$post_type} Style"
			)
		);

		// Add the CSS filename and template name to the array.
		if ( ! empty( $headers['Style Name'] ) )
			$hybrid->post_styles[ $post_type ][ $file ] = $headers['Style Name'];

		elseif ( ! empty( $headers["{$post_type} Style"] ) )
			$hybrid->post_styles[ $post_type ][ $file ] = $headers["{$post_type} Style"];
	}

	// Flip the array of styles.
	$hybrid->post_styles[ $post_type ] = array_flip( $hybrid->post_styles[ $post_type ] );

	// Return array of styles.
	return $hybrid->post_styles[ $post_type ];
}
.htaccess000044400000000424152435123320006340 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>meta-box-post-template.php000060400000010274152435123320011565 0ustar00<?php
/**
 * Adds the template meta box to the post editing screen for public post types.  This feature allows users and
 * devs to create custom templates for any post type, not just pages as default in WordPress core.  The
 * functions in this file create the template meta box and save the template chosen by the user when the
 * post is saved.  This file is only used if the theme supports the 'hybrid-core-template-hierarchy' feature.
 *
 * @package    HybridCore
 * @subpackage Admin
 * @author     Justin Tadlock <justin@justintadlock.com>
 * @copyright  Copyright (c) 2008 - 2015, Justin Tadlock
 * @link       http://themehybrid.com/hybrid-core
 * @license    http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

# Add the post template meta box on the 'add_meta_boxes' hook.
add_action( 'add_meta_boxes', 'hybrid_meta_box_post_add_template',    10, 2 );

# Save the post template meta box data on the 'save_post' hook.
add_action( 'save_post',       'hybrid_meta_box_post_save_template', 10, 2 );
add_action( 'add_attachment',  'hybrid_meta_box_post_save_template'        );
add_action( 'edit_attachment', 'hybrid_meta_box_post_save_template'        );

/**
 * Adds the post template meta box for all public post types, excluding the 'page' post type since WordPress
 * core already handles page templates.
 *
 * @since  1.2.0
 * @access public
 * @param  string  $post_type
 * @param  object  $post
 * @return void
 */
function hybrid_meta_box_post_add_template( $post_type, $post ) {

	// Get the post templates.
	$templates = hybrid_get_post_templates( $post_type );

	// If there's templates, add the meta box.
	if ( ! empty( $templates ) && 'page' !== $post_type )
		add_meta_box( 'hybrid-post-template', esc_html__( 'Template', 'hybrid-core' ), 'hybrid_meta_box_post_display_template', $post_type, 'side', 'default' );
}

/**
 * Displays the post template meta box.
 *
 * @since  1.2.0
 * @access public
 * @param  object  $object
 * @param  array   $box
 * @return void
 */
function hybrid_meta_box_post_display_template( $post, $box ) {

	$templates     = hybrid_get_post_templates( $post->post_type );
	$post_template = hybrid_get_post_template( $post->ID );

	wp_nonce_field( basename( __FILE__ ), 'hybrid-post-template-nonce' ); ?>

	<p>
		<select name="hybrid-post-template" class="widefat">

			<option value=""></option>

			<?php foreach ( $templates as $label => $template ) : ?>
				<option value="<?php echo esc_attr( $template ); ?>" <?php selected( $post_template, $template ); ?>><?php echo esc_html( $label ); ?></option>
			<?php endforeach; ?>

		</select>
	</p>
<?php }

/**
 * Saves the post template meta box settings as post metadata. Note that this meta is sanitized using the
 * hybrid_sanitize_meta() callback function prior to being saved.
 *
 * @since  1.2.0
 * @access public
 * @param  int      $post_id The ID of the current post being saved.
 * @param  object   $post    The post object currently being saved.
 * @return void|int
 */
function hybrid_meta_box_post_save_template( $post_id, $post = '' ) {

	// Fix for attachment save issue in WordPress 3.5. @link http://core.trac.wordpress.org/ticket/21963
	if ( ! is_object( $post ) )
		$post = get_post();

	// Verify the nonce before proceeding.
	if ( ! isset( $_POST['hybrid-post-template-nonce'] ) || ! wp_verify_nonce( $_POST['hybrid-post-template-nonce'], basename( __FILE__ ) ) )
		return $post_id;

	// Return here if the template is not set. There's a chance it won't be if the post type doesn't have any templates.
	if ( ! isset( $_POST['hybrid-post-template'] ) || ! current_user_can( 'edit_post', $post_id ) )
		return $post_id;

	// Get the posted meta value.
	$new_meta_value = sanitize_text_field( $_POST['hybrid-post-template'] );

	// Get the meta value of the meta key.
	$meta_value = hybrid_get_post_template( $post_id );

	// If there is no new meta value but an old value exists, delete it.
	if ( '' == $new_meta_value && $meta_value )
		hybrid_delete_post_template( $post_id );

	// If the new meta value does not match the old value, update it.
	elseif ( $new_meta_value != $meta_value )
		hybrid_set_post_template( $post_id, $new_meta_value );
}
views/FMViewFrommapeditinpopup_fmc.php000060400000007502152435511120014176 0ustar00<?php

class FMViewFrommapeditinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
	$fmc_settings = get_option('fmc_settings');
	$map_key = isset($fmc_settings['map_key']) ? $fmc_settings['map_key'] : '';
    $long = ((isset($_GET['long'])) ? esc_html(stripslashes($_GET['long'])) : 0);
    $lat = ((isset($_GET['lat'])) ? esc_html(stripslashes($_GET['lat'])) : 0);
    ?>
    <script src="<?php echo WD_FMC_URL . '/js/main_front_end.js'; ?>"></script>
    <script src="<?php echo WD_FMC_URL . '/js/if_gmap_back_end.js'; ?>"></script>
    <script src="https://maps.google.com/maps/api/js?v=3.exp&key=<?php echo $map_key ?>" type="text/javascript"></script>
    <table style="margin:0px; padding:0px">
      <tr>
        <td><b>Address:</b></td>
        <td><input type="text" id="addrval0" style="border:0px; background:none" size="80" readonly/></td>
      </tr>
      <tr>
        <td><b>Longitude:</b></td>
        <td><input type="text" id="longval0" style="border:0px; background:none" size="80" readonly/></td>
      </tr>
      <tr>
        <td><b>Latitude:</b></td>
        <td><input type="text" id="latval0" style="border:0px; background:none" size="80" readonly/></td>
      </tr>
    </table>
    <div id="0_elementform_id_temp" long="<?php echo $long ?>" center_x="<?php echo $long ?>" center_y="<?php echo $lat ?>" lat="<?php echo $lat ?>" zoom="8" info="" style="width:600px; height:400px; "></div>
    <script>
      if_gmap_init("0");
      add_marker_on_map(0, 0, "<?php echo $long; ?>", "<?php echo $lat; ?>", "");
    </script>
    <?php
    die();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewGoptions_fmc.php000060400000012637152435511120012123 0ustar00<?php
class FMViewGoptions_fmc {
	////////////////////////////////////////////////////////////////////////////////////////
	// Events                                                                             //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constants                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Variables                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	private $model;

	////////////////////////////////////////////////////////////////////////////////////////
	// Constructor & Destructor                                                           //
	////////////////////////////////////////////////////////////////////////////////////////
	public function __construct($model) {
	$this->model = $model;
	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		$fmc_settings = get_option('fmc_settings');
		$public_key = isset($fmc_settings['public_key']) ? $fmc_settings['public_key'] : '';
		$private_key = isset($fmc_settings['private_key']) ? $fmc_settings['private_key'] : '';
		$csv_delimiter = isset($fmc_settings['csv_delimiter']) ? $fmc_settings['csv_delimiter'] : ',';
		$map_key = isset($fmc_settings['map_key']) ? $fmc_settings['map_key'] : '';
		?>
		<div class="fm-user-manual">
			This section allows you to edit form settings.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form class="wrap" method="post" action="admin.php?page=goptions_fmc" style="width:99%;">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>     
			<div class="fm-page-header">
				<div class="fm-page-title">
					Form Settings
				</div>
				<div class="fm-page-actions">
					<button class="fm-button save-button small" onclick="if (fm_check_required('title', 'Title')) {return false;}; fm_set_input_value('task', 'save');">
						<span></span>
						Save
					</button>
				</div>
			</div>

			<table style="clear:both;">
				<tbody>
					<tr>
						<td>
							<label for="public_key">Recaptcha Site Key:</label>
						</td>
						<td>
							<input type="text" id="public_key" name="public_key" value="<?php echo $public_key; ?>" style="width:250px;" />
						</td>
						<td rowspan="2">
							<a href="https://www.google.com/recaptcha/intro/index.html" target="_blank">Get Recaptcha</a>
						</td>
					</tr>
					<tr>
						<td>
							<label for="private_key">Recaptcha Secret Key:</label>
						</td>
						<td>
							<input type="text" id="private_key" name="private_key" value="<?php echo $private_key; ?>" style="width:250px;" />
						</td>
					</tr>
					<tr>
						<td>
							<label for="public_key">Map API Key:</label>
						</td>
						<td>
							<input type="text" id="map_key" name="map_key" value="<?php echo $map_key; ?>" style="width:250px;" />
						</td>
						<td>
							<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">Get Map API Key</a>
						</td>
					</tr>
					<tr>
						<td>
							
						</td>
						<td>
							<span style="width:250px; display: inline-block; padding: 0 5px;">(It may take up to 5 minutes for API key change to take effect.)</span>
						</td>
						<td>
							
						</td>
					</tr>
					<tr>
						<td>
							<label for="csv_delimiter">CSV Delimiter:</label>
						</td>
						<td>
							<input type="text" id="csv_delimiter" name="csv_delimiter" value="<?php echo $csv_delimiter; ?>" style="width:50px;" />
						</td>
					</tr>
				</tbody>
			</table>
			<input type="hidden" id="task" name="task" value=""/>
		</form>
		<?php
	}



	////////////////////////////////////////////////////////////////////////////////////////
	// Getters & Setters                                                                  //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Private Methods                                                                    //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Listeners                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewBlocked_ips_fmc.php000060400000020331152435511120012525 0ustar00<?php

class FMViewBlocked_ips_fmc {
	////////////////////////////////////////////////////////////////////////////////////////
	// Events                                                                             //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constants                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Variables                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	private $model;

	////////////////////////////////////////////////////////////////////////////////////////
	// Constructor & Destructor                                                           //
	////////////////////////////////////////////////////////////////////////////////////////
	public function __construct($model) {
		$this->model = $model;
	}

	////////////////////////////////////////////////////////////////////////////////////////
	// Public Methods                                                                     //
	////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		$rows_data = $this->model->get_rows_data();
		$page_nav = $this->model->page_nav();
		$search_value = ((isset($_POST['search_value'])) ? esc_html(stripslashes($_POST['search_value'])) : '');	
		$asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
		$order_by_array = array('id', 'ip');
		$order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
		$order_class = 'manage-column column-title sorted ' . $asc_or_desc;
		$ids_string = '';
		?>
		<div id="fm_blocked_ips_message" style="width: 99%; display: none;"></div>
		<div class="fm-user-manual">
			This section allows you to block IPs.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-6.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form onkeypress="fm_doNothing(event)" class="wrap" id="blocked_ips" method="post" action="admin.php?page=blocked_ips_fmc" style="width:99%;">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<div class="fm-page-banner blocked-ips-banner">
				<div class="block_icon">
				</div>
				<div class="fm-logo-title">Blocked IPs</div>
				<div class="fm-page-actions">
					<button class="fm-button save-button small" onclick="fm_set_input_value('task', 'save_all');">
						<span></span>
						Save
					</button>
					<button class="fm-button delete-button small" onclick="if (confirm('Do you want to unblock selected IPs?')) { fm_set_input_value('task', 'delete_all'); } else { return false; }">
						<span></span>
						Delete
					</button>
				</div>
			</div>	 
			<div class="fm-clear"></div>
			<div class="tablenav top">
				<?php
					WDW_FMC_Library::search('IP', $search_value, 'blocked_ips');
					WDW_FMC_Library::html_page_nav($page_nav['total'], $page_nav['limit'], 'blocked_ips');
				?>
			</div>
			<table class="wp-list-table widefat fixed pages fm-block-ip">
				<thead>
					<tr>
						<th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" style="margin: 0;" /></th>
						<th class="table_small_col <?php if ($order_by == 'id') {echo $order_class;} ?>">
							<a onclick="fm_set_input_value('task', '');
                          fm_set_input_value('order_by', 'id');
                          fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'id' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
                          fm_form_submit(event, 'blocked_ips')" href="">
								<span>ID</span><span class="sorting-indicator"></span></th>
							</a>
						<th class="<?php if ($order_by == 'ip') {echo $order_class;} ?>">
							<a onclick="fm_set_input_value('task', '');
                          fm_set_input_value('order_by', 'ip');
                          fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'ip' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
                          fm_form_submit(event, 'blocked_ips')" href="">
							<span>IP</span><span class="sorting-indicator"></span>
							</a>
						</th>
						<th class="table_small_col">Edit</th>
						<th class="table_small_col">Delete</th>
					</tr>		  
					<tr id="tr" style="background-color: #f9f9f9;">
						<th></th>
						<th></th>
						<th>
							<input type="text" class="input_th" id="ip" name="ip" onkeypress="return fm_check_isnum(event)">
							<button class="fm-button add-button small" onclick="if (fm_check_required('ip', 'IP')) {return false;} fm_set_input_value('task', 'save'); fm_set_input_value('current_id', ''); fm_save_ip('blocked_ips');">
								Add IP
								<span></span>
							</button>
						</th>
						<th>
							
						</th>
						<th></th>
					</tr>
				</thead>
			<tbody id="tbody_arr">
			<?php
				if ($rows_data) {
					foreach ($rows_data as $row_data) {
						$alternate = (!isset($alternate) || $alternate == 'class="alternate"') ? '' : 'class="alternate"';
						?>
						<tr id="tr_<?php echo $row_data->id; ?>" <?php echo $alternate; ?>>
						<td class="table_small_col check-column" id="td_check_<?php echo $row_data->id; ?>" >
								<input id="check_<?php echo $row_data->id; ?>" name="check_<?php echo $row_data->id; ?>" type="checkbox" />
							</td>
							<td class="table_small_col" id="td_id_<?php echo $row_data->id; ?>" ><?php echo $row_data->id; ?></td>
							<td id="td_ip_<?php echo $row_data->id; ?>" >
								<a class="pointer" id="ip<?php echo $row_data->id; ?>"
							 onclick="fm_edit_ip(<?php echo $row_data->id; ?>)" 
							 title="Edit"><?php echo $row_data->ip; ?></a>
							</td>
							<td class="table_small_col" id="td_edit_<?php echo $row_data->id; ?>">
								<button class="fm-icon edit-icon" onclick="fm_edit_ip(<?php echo $row_data->id; ?>);">
									<span></span>
								</button>
							</td>
							<td class="table_small_col" id="td_delete_<?php echo $row_data->id; ?>">
								<button class="fm-icon delete-icon" onclick="if (confirm('Do you want to unblock selected IP?')) { fm_set_input_value('task', 'delete'); fm_set_input_value('current_id', <?php echo $row_data->id; ?>); fm_form_submit(event, 'blocked_ips'); } else {return false;}">
									<span></span>
								</button>
							</td>
						</tr>
						<?php
						$ids_string .= $row_data->id . ',';
					}
				}
			?>
			</tbody>
		</table>
		<input id="task" name="task" type="hidden" value="" />
		<input id="current_id" name="current_id" type="hidden" value="" />
		<input id="ids_string" name="ids_string" type="hidden" value="<?php echo $ids_string; ?>" />
		<input id="asc_or_desc" name="asc_or_desc" type="hidden" value="<?php echo $asc_or_desc; ?>" />
		<input id="order_by" name="order_by" type="hidden" value="<?php echo $order_by; ?>" />
    </form>
    <?php
	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFromeditcountryinpopup_fmc.php000060400000021252152435511120015122 0ustar00<?php

class FMViewFromeditcountryinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		$id = ((isset($_GET['field_id'])) ? esc_html(stripslashes($_GET['field_id'])) : 0);
		wp_print_scripts('jquery');
		wp_print_scripts('jquery-ui-core');
		wp_print_scripts('jquery-ui-widget');
		wp_print_scripts('jquery-ui-mouse');
		wp_print_scripts('jquery-ui-slider');
		wp_print_scripts('jquery-ui-sortable');
		
		?>
		<style>
		.country-list {
			padding:10px 0;
		}
		
		.country-list ul {
			font-family: Segoe UI !important;
			font-size:13px;
		}
		.country-list > div {
			display:inline-block;
		}
		
		.save-cancel {
			float:right;
		}
		
		.fm-select-remove {
			background: #4EC0D9;
			width: 78px;
			height: 32px;
			border: 1px solid #4EC0D9;
			border-radius: 6px;
			color: #fff;
			cursor:pointer;
		}
		
		.fm-select-remove.large {
			width: 90px;
		}
		</style>
		<div class="country-list">
			<div class="select-remove">
				<button class="fm-select-remove large" onclick="select_all(); return false;">
					Select all
					<span></span>
				</button>
				<button class="fm-select-remove large" onclick="remove_all(); return false;">
					Remove all
					<span></span>
				</button>
			</div>
			<div class="save-cancel">
				<button class="fm-select-remove" onclick="save_list(); return false;">
					Save
					<span></span>
				</button>
			</div>
			<ul id="countries_list" style="list-style: none; padding: 0px;"></ul>
		</div>	
		<script>
			selec_coutries = [];
			coutries = ["", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo (Brazzaville)", "Congo", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor (Timor Timur)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"];
			select_ = window.parent.document.getElementById('<?php echo $id ?>_elementform_id_temp');
			n = select_.childNodes.length;
			for (i = 0; i < n; i++) {
				selec_coutries.push(select_.childNodes[i].value);
				var ch = document.createElement('input');
					ch.setAttribute("type", "checkbox");
					ch.setAttribute("checked", "checked");
					ch.value = select_.childNodes[i].value;
					ch.id = i + "ch";

				var p = document.createElement('span');
					p.style.cssText = "color:#000000; font-size: 13px; cursor:move";
					p.innerHTML = select_.childNodes[i].value;
				var li = document.createElement('li');
					li.style.cssText = "margin:3px; vertical-align:middle";
					li.id = i;
					li.appendChild(ch);
					li.appendChild(p);
				document.getElementById('countries_list').appendChild(li);
			}
			cur = i;
			m = coutries.length;
			for (i = 0; i < m; i++) {
				isin = isValueInArray(selec_coutries, coutries[i]);
				if (!isin) {
					var ch = document.createElement('input');
						ch.setAttribute("type", "checkbox");
						ch.value = coutries[i];
						ch.id = cur + "ch";

					var p = document.createElement('span');
						p.style.cssText = "color:#000000; font-size: 13px; cursor:move";
						p.innerHTML = coutries[i];
					var li = document.createElement('li');
						li.style.cssText = "margin:3px; vertical-align:middle";
						li.id = cur;
						li.appendChild(ch);
						li.appendChild(p);
					document.getElementById('countries_list').appendChild(li);
					cur++;
				}
			}
			jQuery(function () {
				jQuery("#countries_list").sortable();
				jQuery("#countries_list").disableSelection();
			});

			function isValueInArray(arr, val) {
				inArray = false;
				for (x = 0; x < arr.length; x++) {
					if (val == arr[x]) {
						inArray = true;
					}
				}
				return inArray;
			}
			function save_list() {
				select_.innerHTML = ""
				ul = document.getElementById('countries_list');
				n = ul.childNodes.length;
				for (i = 0; i < n; i++) {
					if (ul.childNodes[i].tagName == "LI") {
						id = ul.childNodes[i].id;
						if (document.getElementById(id + 'ch').checked) {
							var option_ = document.createElement('option');
								option_.setAttribute("value", document.getElementById(id + 'ch').value);
								option_.innerHTML = document.getElementById(id + 'ch').value;
							select_.appendChild(option_);
						}
					}
				}
				window.parent.tb_remove();
			}
			function select_all() {
				for (i = 0; i < 194; i++) {
					document.getElementById(i + 'ch').checked = true;
				}
			}
			function remove_all() {
				for (i = 0; i < 194; i++) {
					document.getElementById(i + 'ch').checked = false;
				}
			}
		</script>
		<?php
		die();
	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewUninstall_fmc.php000060400000013376152435511120012273 0ustar00<?php

class FMViewUninstall_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		global $wpdb;
		$prefix = $wpdb->prefix;
		?>
		<form method="post" action="admin.php?page=uninstall_fmc" style="width:95%;">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<div class="wrap">
				<div class="fm-page-banner uninstall-banner">
					<div class="uninstall_icon">
					</div>
					<div class="fm-logo-title">Uninstall Contact Form Maker</div>
				</div>	 
				<p>
					Deactivating Contact Form Maker plugin does not remove any data that may have been created, such as the Forms and the Submissions. To completely remove this plugin, you can uninstall it here.
				</p>
				<p style="color: red;">
					<strong>WARNING:</strong>
					Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.
				</p>
				<p style="color: red">
					<strong>The following WordPress Options/Tables will be DELETED:</strong>
				</p>
				<table class="widefat">
					<thead>
						<tr>
							<th>Database Tables</th>
						</tr>
					</thead>
					<tr>
						<td valign="top">
							<ol>
								<li><?php echo $prefix; ?>formmaker</li>
								<li><?php echo $prefix; ?>formmaker_backup</li>
								<li><?php echo $prefix; ?>formmaker_blocked</li>
								<li><?php echo $prefix; ?>formmaker_submits</li>
								<li><?php echo $prefix; ?>formmaker_views</li>
								<li><?php echo $prefix; ?>formmaker_themes</li>
								<li><?php echo $prefix; ?>formmaker_sessions</li>
								<li><?php echo $prefix; ?>formmaker_query</li>

							</ol>
						</td>
					</tr>
				</table>
				<p style="text-align: center;">
					Do you really want to uninstall Contact Form Maker?
				</p>
				<p style="text-align: center;">
					<input type="checkbox" name="Contact Form Maker" id="check_yes" value="yes" />&nbsp;<label for="check_yes">Yes</label>
				</p>
				<p style="text-align: center;">
					<input type="submit" value="UNINSTALL" class="button-primary" onclick="if (check_yes.checked) {  if (confirm('You are About to Uninstall Contact Form Maker from WordPress.\nThis Action Is Not Reversible.')) { fm_set_input_value('task', 'uninstall'); } else { return false; } } else { return false; }" />
				</p>
			</div>
			<input id="task" name="task" type="hidden" value="" />
		</form>
		<?php
	}

  public function uninstall() {
    $this->model->delete_db_tables();
    global $wpdb;
    $prefix = $wpdb->prefix;
    $deactivate_url = add_query_arg(array('action' => 'deactivate', 'plugin' => 'contact-form-maker/contact-form-maker.php'), admin_url('plugins.php'));
    $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_contact-form-maker/contact-form-maker.php');
    ?>
    <div id="message" class="updated fade">
        <p>The following Database Tables succesfully deleted:</p>
        <p><?php echo $prefix; ?>formmaker,</p>
        <p><?php echo $prefix; ?>formmaker_backup,</p>
        <p><?php echo $prefix; ?>formmaker_blocked,</p>
        <p><?php echo $prefix; ?>formmaker_sessions,</p>
        <p><?php echo $prefix; ?>formmaker_submits,</p>
        <p><?php echo $prefix; ?>formmaker_themes,</p>
        <p><?php echo $prefix; ?>formmaker_views.</p>
        <p><?php echo $prefix; ?>formmaker_query.</p>
    </div>
    <div class="wrap">
      <h2>Uninstall Contact Form Maker</h2>
      <p><strong><a href="<?php echo $deactivate_url; ?>">Click Here</a> To Finish the Uninstallation and Contact Form Maker will be Deactivated Automatically.</strong></p>
      <input id="task" name="task" type="hidden" value="" />
    </div>
  <?php
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFormMakerEditCSS_fmc.php000060400000016311152435511120013354 0ustar00<?php

class FMViewFormMakerEditCSS_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
    $theme_id = ((isset($_GET['id'])) ? esc_html(stripslashes($_GET['id'])) : '');
    $form_id = ((isset($_GET['form_id'])) ? esc_html(stripslashes($_GET['form_id'])) : 0);
    $row = $this->model->get_theme_row($theme_id);
    wp_print_scripts('jquery');
        
    ?>
    <link media="all" type="text/css" href="<?php echo get_admin_url(); ?>load-styles.php?c=1&amp;dir=ltr&amp;load=admin-bar,dashicons,wp-admin,buttons,wp-auth-check" rel="stylesheet">
    <link media="all" type="text/css" href="<?php echo get_admin_url(); ?>css/colors<?php echo ((get_bloginfo('version') < '3.8') ? '-fresh' : ''); ?>.min.css" id="colors-css" rel="stylesheet">
    <link media="all" type="text/css" href="<?php echo WD_FMC_URL . '/css/form_maker_tables.css'; ?>" rel="stylesheet">
    <script src="<?php echo WD_FMC_URL . '/js/form_maker_admin.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/codemirror.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/formatting.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/css.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/clike.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/javascript.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/htmlmixed.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/xml.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/layout/php.js'; ?>" type="text/javascript"></script>
    <link media="all" type="text/css" href="<?php echo WD_FMC_URL . '/css/codemirror.css'; ?>" rel="stylesheet">
    
    <style>
		.CodeMirror {
			border: 1px solid #ccc;
			font-size: 12px;
			margin-bottom: 6px;
			background: white;
		}
    </style>

    <form id="fm_theme" class="wrap wp-core-ui" method="post" action="#" style="width: 99%; padding-left:3px;">
		<div class="fm-page-header">
			<div class="fm-page-actions">
				<button class="fm-button save-button small" onclick="if (fm_check_required('title', 'Theme title')) {return false;}; fm_save_theme('save'); window.parent.jQuery('#theme option[value=<?php echo $theme_id; ?>]').html(jQuery('#title').val()); window.parent.tb_remove();">
					<span></span>
					Save
				</button>
				<button class="fm-button apply-button small" onclick="if (fm_check_required('title', 'Theme title')) {return false;}; fm_save_theme('apply'); window.parent.jQuery('#theme option[value=<?php echo $theme_id; ?>]').html(jQuery('#title').val()); return false;">
					<span></span>
					Apply
				</button>
				<button class="fm-button save-as-copy-button medium" onclick="if (fm_check_required('title', 'Theme title')) {return false;}; fm_save_theme('save_as_new'); window.parent.jQuery('#theme').append('<option value=0>' + jQuery('#title').val() + '</option>'); window.parent.tb_remove(); return false;">
					<span></span>
					Save as New
				</button>
				<button class="fm-button undo-button small" onclick="fm_reset_theme(); return false;">
					<span></span>
					Reset
				</button>
				<button class="fm-button cancel-button small" onclick="window.parent.tb_remove();">
					<span></span>
					Cancel
				</button>
			</div>
			<div class="fm-clear"></div>
		</div>
		<table style="clear: both;">
			<tbody>
				<tr>
					<td class="fm_label"><label for="title">Theme title: <span style="color:#FF0000;"> * </span> </label></td>
					<td><input type="text" id="title" name="title" value="<?php echo $row->title; ?>" class="fm_text_input" /></td>
				</tr>
				<tr>
					<td class="fm_label"><label for="css">Css: </label></td>
					<td style="width: 90%;"><textarea id="css" name="css" rows="25" style="width: 100%;"><?php echo htmlspecialchars($row->css); ?></textarea></td>
				</tr>
			</tbody>
		</table>
		<div style="display: none;" id="main_theme"><?php echo str_replace('"', '\"', $row->css); ?></div>
		<input type="hidden" id="task" name="task" value="" />
		<input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
		<input type="hidden" id="default" name="default" value="<?php echo $row->default; ?>" />
		<input type="hidden" name="form_id" id="form_id" value="<?php echo $form_id; ?>" />
    </form>
    <script>
		var editor = CodeMirror.fromTextArea(
			document.getElementById("css"), {
			lineNumbers: true,
			lineWrapping: true,
			mode: "css"
		});
      
		CodeMirror.commands["selectAll"](editor);
		editor.autoFormatRange(editor.getCursor(true), editor.getCursor(false));
		editor.scrollTo(0,0);
		
		function fm_save_theme(task) {
			fm_set_input_value('task', task);
			document.getElementById('fm_theme').submit();
		}
		
		function fm_reset_theme() {
			editor.setValue(jQuery('#main_theme').html())
			jQuery('#css').val(jQuery('#main_theme').html()); 
		}
		
    </script>
    <?php
    die();
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewLicensing_fmc.php000060400000010514152435511120012224 0ustar00<?php

class FMViewLicensing_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
	wp_register_style('fm_license', WD_FMC_URL . '/css/license.css', array(), get_option("wd_form_maker_version"));
	wp_print_styles('fm_license');
    ?>
    <div style="width:99%">
      <div id="featurs_tables">
		  <div id="featurs_table1">
			<span>Unlimited Fields</span>
			<span>File Upload Field</span>
			<span>Google Map</span>
			<span>PayPal Integration</span>
			<span>Front-End Submissions</span>
			<span>Add-ons support</span>
		  </div>
		  <div id="featurs_table2">
			<span>Free</span>
			<span class="no"></span>
			<span class="no"></span>
			<span class="no"></span>
			<span class="no"></span>
			<span class="no"></span>
			<span class="no"></span>
		  </div>
		  <div id="featurs_table3">
			<span>Pro Version</span>
			<span class="yes"></span>
			<span class="yes"></span>
			<span class="yes"></span>
			<span class="yes"></span>
			<span class="yes"></span>
			<span class="yes"></span>
		  </div>
		</div>
	<div style="float: right; text-align: right;">
        <a style="text-decoration: none;" target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
          <img width="215" border="0" alt="web-dorado.com" src="<?php echo WD_FMC_URL . '/images/wd_logo.png'; ?>" />
        </a>
      </div>
	<div style="float: left; clear: both;">
      <a href="https://web-dorado.com/files/fromContactForm.php" class="button-primary" target="_blank">Purchase a License</a>
      <br/><br/>
      <p>After purchasing the commercial version follow these steps:</p>
      <ol>
        <li>Deactivate Contact Form Maker Plugin.</li>
        <li>Delete Contact Form Maker Plugin.</li>
        <li>Install the downloaded commercial version of the plugin.</li>
      </ol>
      <br/>
      <p>If you enjoy using Contact Form Maker and find it useful, please consider making a donation. Your donation will help encourage and support the plugin's continued development and better user support.</p>
      <br/>
      <a href="https://web-dorado.com/files/donate_redirect.php" target="_blank">
	  <div class="fm-get-pro"></div>
	  </a>
    </div>
    <?php
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFormcontactwdmathcaptcha.php000060400000012664152435511120014504 0ustar00<?php

class FMViewFormcontactwdmathcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		if (isset($_GET['action']) && esc_html($_GET['action']) == 'formcontactwdmathcaptcha') {
			$i = (isset($_GET["i"]) ? esc_html($_GET["i"]) : '');
			$r2 = (isset($_GET["r2"]) ? (int) $_GET["r2"] : 0);
			$rrr = (isset($_GET["rrr"]) ? (int) $_GET["rrr"] : 0);
			$randNum = 0 + $r2 + $rrr;
			$operations_count = ((isset($_GET["operations_count"]) && (int)$_GET["operations_count"]) ? ((int)$_GET["operations_count"] > 5 ? 5 : (int)$_GET["operations_count"]) : 1);
			$operations = (isset($_GET["operations"]) ? str_replace('@', '+', $_GET["operations"]) : '+,-');
			$operations = preg_replace('/\s+/', '', $operations);
			$cap_width = 2*($operations_count+1) * 20 + 10;
			$cap_height = 26;
			$cap_quality = 100;
	  
			$code = $this->code_generic($operations_count, $operations);
			if (session_id() == '' || (function_exists('session_status') && (session_status() == PHP_SESSION_NONE))) {
				@session_start();
			}
			
			$_SESSION[$i . '_wd_arithmetic_captcha_code'] = md5($code[1]);
			$canvas = imagecreatetruecolor($cap_width, $cap_height);
			
			$c = imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255));
			imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c);
			$code = $code[0];
			$count = strlen($code);
			$color_text = imagecolorallocate($canvas, 0, 0, 0);
			for ($it = 0; $it < $count; $it++) {
				$letter = $code[$it];
				imagestring($canvas, 6, (10 * $it + 10), $cap_height / 4, $letter, $color_text);
			}
			for ($c = 0; $c < 150; $c++) {
				$x = rand(0, $cap_width - 1);
				$y = rand(0, 29);
				$col = '0x' . rand(0, 9) . '0' . rand(0, 9) . '0' . rand(0, 9) . '0';
				imagesetpixel($canvas, $x, $y, $col);
			}
			header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
			header('Cache-Control: no-store, no-cache, must-revalidate');
			header('Cache-Control: post-check=0, pre-check=0', FALSE);
			header('Pragma: no-cache');
			header('Content-Type: image/jpeg');
			imagejpeg($canvas, NULL, $cap_quality);
		}
		die('');
	}

	private function code_generic($_length, $_operations) {
		$cap = '';
        $dig = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
		$valid_oprations = array('+', '-', '*', '/');
		$operations_array = array_filter(explode(',', $_operations));
		foreach($operations_array as $key => $operation) {
			if(!in_array($operation, $valid_oprations))
				unset($operations_array[$key]);
		}
		
		for($k=0; $k <= $_length; $k++) {
			if(substr($cap, -1) == '/' ) {
				$operations_array = array_diff($operations_array, array('/'));
				$num_divisors = $this->arrayOfNumberDivisors(substr($cap, -2, 1));
				$cap .= $num_divisors[array_rand($num_divisors)];
			}	
			else
				$cap .= $dig[array_rand($dig)];
	
			if($k != $_length)
				$cap .= $operations_array[array_rand($operations_array)];
		}
		$pass = eval('return '.$cap.';');
		if($pass < 0)
			return $this->code_generic($_length, $_operations);
		$cap .= '=';
		$cap = implode(' ',str_split($cap));

        return array($cap, $pass);
    }
  
	public function arrayOfNumberDivisors($x) {
		$divisors = array ();
		if($x == 0)
			$divisors[] = rand(1, 9);
			
		for($i = 1; $i <= $x; $i ++) {
			if ($x % $i == 0) {
				$divisors [] = $i;
			}
		}
		return $divisors;
	}
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewManage_fmc.php000060400000701647152435511120011517 0ustar00<?php

class FMViewManage_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;

  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		$rows_data = $this->model->get_rows_data();
		$page_nav = $this->model->page_nav();
		$search_value = ((isset($_POST['search_value'])) ? esc_html($_POST['search_value']) : '');
		$search_select_value = ((isset($_POST['search_select_value'])) ? (int) $_POST['search_select_value'] : 0);
		$asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
		$order_by_array = array('id', 'title', 'mail');
		$order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
		$order_class = 'manage-column column-title sorted ' . $asc_or_desc;
		$ids_string = '';
		?>
		<div class="fm-user-manual">
			This section allows you to create, edit forms.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form onkeypress="fm_doNothing(event)" class="wrap" id="manage_form" method="post" action="admin.php?page=manage_fmc" style="width:99%;">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<div class="fm-page-banner">
				<div class="fm-logo">
				</div>
				<div class="fm-logo-title">Contact Form</br>Maker</div>
				<button class="fm-button add-button medium" onclick="fm_set_input_value('task', 'add'); fm_form_submit(event, 'manage_form')">
					<span></span>
					Add New
				</button>
			</div>	 
			<div class="tablenav top">
			<?php
				WDW_FMC_Library::search('Title', $search_value, 'manage_form');
				WDW_FMC_Library::html_page_nav($page_nav['total'], $page_nav['limit'], 'manage_form');
			?>
			</div>
			<table class="wp-list-table widefat fixed pages">
				<thead>
					<th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" style="margin:0;"/></th>
					<th class="table_small_col <?php if ($order_by == 'id') { echo $order_class; } ?>">
						<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'id'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'id' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'manage_form')" href="">
						<span>ID</span><span class="sorting-indicator"></span></a>
					</th>
					<th class="<?php if ($order_by == 'title') { echo $order_class; } ?>">
						<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'title'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'title' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'manage_form')" href="">
						<span>Title</span><span class="sorting-indicator"></span></a>
					</th>
					<th class="<?php if ($order_by == 'mail') { echo $order_class; } ?>">
						<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'mail'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'mail' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'manage_form')" href="">
						<span>Email to send submissions to</span><span class="sorting-indicator"></span></a>
					</th>
					<th class="table_big_col">Shortcode</th>
					<th class="table_large_col">PHP function</th>
					<th class="table_small_col">Edit</th>
					<th class="table_small_col">
						<a title="Delete selected items" href="" onclick="if (confirm('Do you want to delete selected items?')) { fm_set_input_value('task', 'delete_all'); fm_form_submit(event, 'manage_form'); } else { return false; }">Delete</a>
					</th>
				</thead>
				<tbody id="tbody_arr">
					<?php
					if ($rows_data) {
						foreach ($rows_data as $row_data) {
							$alternate = (!isset($alternate) || $alternate == '') ? 'class="alternate"' : '';
							$old = '';
							if (isset($row_data->form) && ($row_data->form != '')) {
								$old = '_old';
							}
							?>
							<tr id="tr_<?php echo $row_data->id; ?>" <?php echo $alternate; ?>>
								<td class="table_small_col check-column">
									<input id="check_<?php echo $row_data->id; ?>" name="check_<?php echo $row_data->id; ?>" type="checkbox"/>
								</td>
								<td class="table_small_col"><?php echo $row_data->id; ?></td>
								<td>
									<a onclick="fm_set_input_value('task', 'edit<?php echo $old; ?>'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'manage_form')" href="" title="Edit"><?php echo $row_data->title; ?></a>
								</td>
								<td><?php echo $row_data->mail; ?></td>
								<td class="table_big_col" style="padding-left: 0; padding-right: 0;">
									<input type="text" value='[wd_contact_form id="<?php echo $row_data->id; ?>"]' onclick="fm_select_value(this)" size="12" readonly="readonly" style="padding-left: 1px; padding-right: 1px;"/>
								</td>
								<td class="table_large_col" style="padding-left: 0; padding-right: 0;">
									<input type="text" value='&#60;?php wd_contact_form_maker(<?php echo $row_data->id; ?>); ?&#62;' onclick="fm_select_value(this)"  readonly="readonly" style="padding-left: 1px; padding-right: 1px;"/>
								</td>
								<td class="table_small_col">
									<button class="fm-icon edit-icon" onclick="fm_set_input_value('task', 'edit<?php echo $old; ?>');  fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'manage_form')">
										<span></span>
									</button>
								</td>
								<td class="table_small_col">
									<button class="fm-icon delete-icon" onclick="if (confirm('Do you want to delete selected item(s)?')) { fm_set_input_value('task', 'delete'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'manage_form'); } else { return false; }">
										<span></span>
									</button>
								</td>
							</tr>
							<?php
							$ids_string .= $row_data->id . ',';
						}
					}
					?>
				</tbody>
			</table>
			<input id="task" name="task" type="hidden" value=""/>
			<input id="current_id" name="current_id" type="hidden" value=""/>
			<input id="ids_string" name="ids_string" type="hidden" value="<?php echo $ids_string; ?>"/>
			<input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc"/>
			<input id="order_by" name="order_by" type="hidden" value="<?php echo $order_by; ?>"/>
		</form>
		<?php
	}

	public function edit($id) {
		?>
		<img src="<?php echo WD_FMC_URL . '/images/buttons.png'; ?>" style="display:none;"/>
		<?php
		$row = $this->model->get_row_data_new($id);
		$themes = $this->model->get_theme_rows_data();
		$labels = array();
		$label_id = array();
		$label_order_original = array();
		$label_type = array();
		$label_all = explode('#****#', $row->label_order);
		$label_all = array_slice($label_all, 0, count($label_all) - 1);
		foreach ($label_all as $key => $label_each) {
			$label_id_each = explode('#**id**#', $label_each);
			array_push($label_id, $label_id_each[0]);
			$label_oder_each = explode('#**label**#', $label_id_each[1]);
			array_push($label_order_original, addslashes($label_oder_each[0]));
			array_push($label_type, $label_oder_each[1]);
		}
		$labels['id'] = '"' . implode('","', $label_id) . '"';
		$labels['label'] = '"' . implode('","', $label_order_original) . '"';
		$labels['type'] = '"' . implode('","', $label_type) . '"';
		$page_title = (($id != 0) ? 'Edit form ' . $row->title : 'Create new form');
		?>
		<script type="text/javascript">
			var plugin_url = "<?php echo WD_FMC_URL; ?>";
			var field_limitation = "<?php echo get_option("wd_cfield_limit", ''); ?>";
		</script>
		<script src="<?php echo WD_FMC_URL . '/js/formmaker_div_free.js'; ?>?ver=<?php echo get_option("wd_form_maker_version"); ?>" type="text/javascript"></script>
		<script type="text/javascript">
			form_view = 1;
			form_view_count = 1;
			form_view_max = 1;
			function submitbutton() {
			<?php if ($id) { ?>
				if (!document.getElementById('araqel') || (document.getElementById('araqel').value == '0')) {
					alert('Please wait while page loading.');
					return false;
				}
			<?php } ?>
			tox = '';
			form_fields = '';
			document.getElementById('take').style.display = "none";
			document.getElementById('page_bar').style.display = "none";
			jQuery('#saving').html('<div class="fm-loading-container"><div class="fm-loading-content"></div></div>');
			jQuery('.wdform_section').each(function() {
				var this2 = this;
				jQuery(this2).find('.wdform_column').each(function() {
					if(!jQuery(this).html() && jQuery(this2).children().length>1)
						jQuery(this).remove();
				});
			});
			remove_whitespace(document.getElementById('take'));
			l_id_array = [<?php echo $labels['id']?>];
			l_label_array = [<?php echo $labels['label']?>];
			l_type_array = [<?php echo $labels['type']?>];
			l_id_removed = [];      
			for (x = 0; x < l_id_array.length; x++) {
				l_id_removed[l_id_array[x]] = true;
			}
			for (t = 1; t <= form_view_max; t++) {
			  if (document.getElementById('form_id_tempform_view' + t)) {
				wdform_page = document.getElementById('form_id_tempform_view' + t);
				remove_whitespace(wdform_page);
				n = wdform_page.childNodes.length - 2;
				for (q = 0; q <= n; q++) {
				  if (!wdform_page.childNodes[q].getAttribute("wdid")) {
					wdform_section = wdform_page.childNodes[q];
					for (x = 0; x < wdform_section.childNodes.length; x++) {
					  wdform_column = wdform_section.childNodes[x];
					  if (wdform_column.firstChild) {
						for (y=0; y < wdform_column.childNodes.length; y++) {
						  is_in_old = false;
						  wdform_row = wdform_column.childNodes[y];
						  if (wdform_row.nodeType == 3) {
							continue;
						  }
						  wdid = wdform_row.getAttribute("wdid");
						  if (!wdid) {
							continue;
						  }
						  l_id = wdid;
						  l_label = document.getElementById(wdid + '_element_labelform_id_temp').innerHTML;
						  l_label = l_label.replace(/(\r\n|\n|\r)/gm," ");
						  wdtype = wdform_row.firstChild.getAttribute('type');

						  for (var z = 0; z < l_id_array.length; z++) {
							if (l_type_array[z] == "type_address") {
								if (document.getElementById(l_id + "_mini_label_street1") || document.getElementById(l_id + "_mini_label_street2") || document.getElementById(l_id + "_mini_label_city") || document.getElementById(l_id + "_mini_label_state") || document.getElementById(l_id+"_mini_label_postal") || document.getElementById(l_id+"_mini_label_country")) {
								  l_id_removed[l_id_array[z]] = false;
								}
							}
							else {
								if (l_id_array[z] == wdid) {
									l_id_removed[l_id] = false;
								}
							}
							
						  }

						  if (wdtype == "type_address") {
							addr_id = parseInt(wdid);
							id_for_country = addr_id;
							if (document.getElementById(id_for_country + "_mini_label_street1"))
							  tox = tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_street1").innerHTML + '#**label**#type_address#****#';
							addr_id++; 
							if (document.getElementById(id_for_country + "_mini_label_street2"))
							  tox = tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_street2").innerHTML + '#**label**#type_address#****#';
							addr_id++;
							if (document.getElementById(id_for_country+"_mini_label_city"))
							  tox = tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_city").innerHTML + '#**label**#type_address#****#';
							addr_id++;
							if (document.getElementById(id_for_country + "_mini_label_state"))
							  tox = tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_state").innerHTML + '#**label**#type_address#****#';
							addr_id++;
							if (document.getElementById(id_for_country + "_mini_label_postal"))
							  tox = tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_postal").innerHTML + '#**label**#type_address#****#';
							addr_id++;
							if (document.getElementById(id_for_country+"_mini_label_country")) {
							  tox=tox + addr_id + '#**id**#' + document.getElementById(id_for_country + "_mini_label_country").innerHTML + '#**label**#type_address#****#';
							}
							
						  }
						  else {
							tox = tox + wdid + '#**id**#' + l_label + '#**label**#' + wdtype + '#****#';
						  }
						
						  id = wdid;
						  form_fields += wdid + "*:*id*:*";
						  form_fields += wdtype + "*:*type*:*";
						  w_choices = new Array();
						  w_choices_value=new Array();
						  w_choices_checked = new Array();
						  w_choices_disabled = new Array();
						  w_choices_params =new Array();
						  w_allow_other_num = 0;
						  w_property = new Array();
						  w_property_type = new Array();
						  w_property_values = new Array();
						  w_choices_price = new Array();
						  if (document.getElementById(id+'_element_labelform_id_temp').innerHTML) {
							w_field_label = document.getElementById(id + '_element_labelform_id_temp').innerHTML.replace(/(\r\n|\n|\r)/gm," ");
						  }
						  else {                      
							w_field_label = " ";
						  }
						  if (document.getElementById(id + '_label_sectionform_id_temp')) {
							if (document.getElementById(id + '_label_sectionform_id_temp').style.display == "block") {
							  w_field_label_pos = "top";
							}
							else {
							  w_field_label_pos = "left";
							}
						  }
						  if (document.getElementById(id + "_elementform_id_temp")) {
							s = document.getElementById(id + "_elementform_id_temp").style.width;
							w_size=s.substring(0,s.length - 2);
						  }
						  if (document.getElementById(id + "_label_sectionform_id_temp")) {
							s = document.getElementById(id + "_label_sectionform_id_temp").style.width;
							w_field_label_size = s.substring(0, s.length - 2);
						  }
						  if (document.getElementById(id + "_requiredform_id_temp")) {
							w_required = document.getElementById(id + "_requiredform_id_temp").value;
						  }
						  if (document.getElementById(id + "_uniqueform_id_temp")) {
							w_unique = document.getElementById(id + "_uniqueform_id_temp").value;
						  }
						  if (document.getElementById(id + '_label_sectionform_id_temp')) {
							w_class = document.getElementById(id + '_label_sectionform_id_temp').getAttribute("class");
							if (!w_class) {
							  w_class = "";
							}
						  }
						  gen_form_fields();
						  wdform_row.innerHTML = "%" + id + " - " + l_label + "%";
						}
					  }
					}
				  }
				  else {
					id = wdform_page.childNodes[q].getAttribute("wdid");
					w_editor = document.getElementById(id + "_element_sectionform_id_temp").innerHTML;
					form_fields += id + "*:*id*:*";
					form_fields += "type_section_break" + "*:*type*:*";
					form_fields += "custom_" + id + "*:*w_field_label*:*";
					form_fields += w_editor + "*:*w_editor*:*";
					form_fields += "*:*new_field*:*";
					wdform_page.childNodes[q].innerHTML = "%" + id + " - " + "custom_" + id + "%";
				  }
				}
			  }	
			}
			document.getElementById('label_order_current').value = tox;

			for (x = 0; x < l_id_array.length; x++) {
				if (l_id_removed[l_id_array[x]]) {
					tox = tox + l_id_array[x] + '#**id**#' + l_label_array[x] + '#**label**#' + l_type_array[x] + '#****#';
				}
			}

			document.getElementById('label_order').value = tox;
			document.getElementById('form_fields').value = form_fields;
			refresh_(); 
			document.getElementById('pagination').value=document.getElementById('pages').getAttribute("type");
			document.getElementById('show_title').value=document.getElementById('pages').getAttribute("show_title");
			document.getElementById('show_numbers').value=document.getElementById('pages').getAttribute("show_numbers");
			return true;
		}

		gen = <?php echo (($id != 0) ? $row->counter : 1); ?>;

		function enable() {
			alltypes = Array('customHTML', 'text', 'checkbox', 'radio', 'time_and_date', 'select', 'file_upload', 'captcha', 'map', 'button', 'page_break', 'section_break', 'paypal', 'survey');
			for (x = 0; x < 14; x++) {
				document.getElementById('img_' + alltypes[x]).src = "<?php echo WD_FMC_URL . '/images/'; ?>" + alltypes[x] + ".png?ver=<?php echo get_option("wd_form_maker_version"); ?>";
			}
			if (document.getElementById('formMakerDiv').style.display == 'block') {
				jQuery('#formMakerDiv').slideToggle(200);
			}
			else {
				jQuery('#formMakerDiv').slideToggle(400);
			}
			
			if (document.getElementById('formMakerDiv1').style.display == 'block') {
				jQuery('#formMakerDiv1').slideToggle(200);
			}
			else {
				jQuery('#formMakerDiv1').slideToggle(400);
			}
			document.getElementById('when_edit').style.display = 'none';
		}

		function enable2() {
			alltypes = Array('customHTML', 'text', 'checkbox', 'radio', 'time_and_date', 'select', 'file_upload', 'captcha', 'map', 'button', 'page_break', 'section_break', 'paypal', 'survey');
			for (x = 0; x < 14; x++) {
				document.getElementById('img_' + alltypes[x]).src = "<?php echo WD_FMC_URL . '/images/'; ?>" + alltypes[x] + ".png?ver=<?php echo get_option("wd_form_maker_version"); ?>";
			}
			if (document.getElementById('formMakerDiv').style.display == 'block') {
				jQuery('#formMakerDiv').slideToggle(200);
			}
			else {
				jQuery('#formMakerDiv').slideToggle(400);
			}
			
			if (document.getElementById('formMakerDiv1').style.display == 'block') {
				jQuery('#formMakerDiv1').slideToggle(200);
			}
			else {
				jQuery('#formMakerDiv1').slideToggle(400);
			}
			document.getElementById('when_edit').style.display = 'block';
			if (document.getElementById('field_types').offsetWidth) {
				document.getElementById('when_edit').style.width = document.getElementById('field_types').offsetWidth + 'px';
			}
			if (document.getElementById('field_types').offsetHeight) {
				document.getElementById('when_edit').style.height = document.getElementById('field_types').offsetHeight + 'px';
			}
		}
		</script>
		<div class="fm-user-manual">
			This section allows you to add fields to your form.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-4.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form class="wrap" id="manage_form" method="post" action="admin.php?page=manage_fmc" style="width:99%;">
		<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<h2 class="fm-h2-message"></h2>
			<div class="fm-page-header">
				<!-- <div class="fm-page-title">
					<?php echo $page_title; ?>
				</div> -->
				<div style="float:left;">
					<div class="fm-logo-edit-page"></div>
					<div class="fm-title-edit-page">Contact Form</br>Maker</div>
				</div>
				<div class="fm-page-actions">
					<button class="fm-button form-options-button medium" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'form_options');">
						<span></span>
						Form Options
					</button>	
					<button class="fm-button form-layout-button medium" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'form_layout');">
						<span></span>
						Form Layout
					</button>	
					<div style="height:40px; border-right: 1px solid #848484; display: inline-block; width: 5px; vertical-align: bottom; margin-right: 5px;"></div>		
					<?php
					if(isset($row->backup_id) )
						if($row->backup_id!="") {
							global $wpdb;
							$query = "SELECT backup_id FROM " . $wpdb->prefix . "formmaker_backup WHERE backup_id > ".$row->backup_id." AND id = ".$row->id." ORDER BY backup_id ASC LIMIT 0 , 1 ";
							$backup_id = $wpdb->get_var($query);
							if($backup_id) { ?>
								<button class="fm-button redo-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; jQuery('#saving_text').html('Redo');fm_set_input_value('task', 'redo');">
									<span></span>
									Redo
								</button>
								<?php 
							}
							$query = "SELECT backup_id FROM " . $wpdb->prefix . "formmaker_backup WHERE backup_id < ".$row->backup_id." AND id = ".$row->id." ORDER BY backup_id DESC LIMIT 0 , 1 ";
							$backup_id = $wpdb->get_var($query);

							if($backup_id) { ?>
								<button class="fm-button undo-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; jQuery('#saving_text').html('Undo');fm_set_input_value('task', 'undo');">
									<span></span>
									Undo
								</button>
								<?php
							}
						}
						?>
					
					<?php if ($id) { ?>
						<button class="fm-button save-as-copy-button medium" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'save_as_copy');">
							<span></span>
							Save as Copy
						</button>
					<?php } ?>
					<button class="fm-button save-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'save');">
						<span></span>
						Save
					</button>
					<button class="fm-button apply-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'apply');">
						<span></span>
						Apply
					</button>
					<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', 'cancel');">
						<span></span>
						Cancel
					</button>
				</div>
				<div class="fm-clear"></div>
			</div>
			<div class="fm-title">
				<span style="">Form title:&nbsp;</span>
				<input id="title" name="title" value="<?php echo $row->title; ?>"/>
			</div>
			<div class="fm-clear"></div>
			<br/>
			<div class="fm-theme-banner">
				<div class="fm-theme" style="float:left;">
					
					<span style="">Theme:&nbsp;</span>
					<select id="theme" name="theme" onChange="set_preview()">
						<?php
						foreach ($themes as $theme) {
							?>
							<option value="<?php echo $theme->id; ?>" <?php echo (($theme->id == $row->theme) ? 'selected' : ''); ?>><?php echo $theme->title; ?></option>
							<?php
						}
						?>
					</select>
					<button id="preview_form" class="fm-button preview-button small" onclick="tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id, 'test_theme' => $row->theme, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>'); return false;">
						<span></span>
						Preview
					</button>
					<button id="edit_css" class="fm-button options-edit-button small" onclick="tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'id' => $row->theme, 'form_id' => $row->id, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>'); return false;">
						<span></span>
						Edit CSS
					</button>
				</div>
				<div style="float:right;">
					<button class="fm-button add-new-button large" onclick="enable(); Enable(); return false;">
						Add a New Field
						<span></span>
					</button>
				</div>	
			</div>
			<div class="fm-clear"></div>
			<div id="formMakerDiv" onclick="close_window()"></div>
				<div id="formMakerDiv1">
					<table class="formMakerDiv1_table" border="0" width="100%" cellpadding="0" cellspacing="0" height="100%">
						<tr>
							<td style="padding:0px">
								<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" >
									<tr valign="top">
										<td width="20%" height="100%" id="field_types">
											<div id="when_edit" style="display: none;"></div>
											<table border="0" cellpadding="0" cellspacing="3" width="100%" style="border-collapse: separate; border-spacing: 3px;">
												<tbody>
													<tr>
														<td align="center" onclick="addRow('customHTML')" class="field_buttons" id="table_editor">
															<img src="<?php echo WD_FMC_URL; ?>/images/customHTML.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_customHTML">
															<div>Custom HTML</div>
														</td>
														<td align="center" onclick="addRow('text')" class="field_buttons" id="table_text">
															<img src="<?php echo WD_FMC_URL; ?>/images/text.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_text">
															<div>Text input</div>
														</td>
													</tr>
													<tr>
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_checkbox">
															<img src="<?php echo WD_FMC_URL; ?>/images/checkbox.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_checkbox">
															<div>Multiple Choice</div>
														</td>
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_radio">
															<img src="<?php echo WD_FMC_URL; ?>/images/radio.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_radio">
															<div>Single Choice</div>
														</td>
													</tr>
													<tr>
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_survey">
															<img src="<?php echo WD_FMC_URL; ?>/images/survey.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_survey">
															<div>Survey Tools</div>
														</td>           
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_time_and_date">
															<img src="<?php echo WD_FMC_URL; ?>/images/time_and_date.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_time_and_date">
															<div>Time and Date</div>
														</td>
												   </tr>
													<tr>
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_select">
															<img src="<?php echo WD_FMC_URL; ?>/images/select.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_select">
															<div>Select Box</div>
														</td>
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" class="field_buttons field_disabled" id="table_file_upload">
															<img src="<?php echo WD_FMC_URL; ?>/images/file_upload.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_file_upload">
															<div>File Upload</div>
														</td>
													</tr>
													<tr>
														<td align="center" onclick="addRow('section_break')" class="field_buttons" id="table_section_break">
															<img src="<?php echo WD_FMC_URL; ?>/images/section_break.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_section_break">
															<div>Section Break</div>
														</td>
														<td align="center" onclick="addRow('page_break')" class="field_buttons" id="table_page_break">
															<img src="<?php echo WD_FMC_URL; ?>/images/page_break.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_page_break">
															<div>Page Break</div>
														</td>  
													</tr>
													<tr>
														<td align="center" onclick="addRow('map')" class="field_buttons" id="table_map">
															<img src="<?php echo WD_FMC_URL; ?>/images/map.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_map">
															<div>Map</div>
														</td>  
														<td align="center" onclick="alert('This field type is disabled in free version. If you need this functionality, you need to buy the commercial version.')" id="table_paypal" class="field_buttons field_disabled">
															<img src="<?php echo WD_FMC_URL; ?>/images/paypal.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_paypal">
															<div>PayPal</div>
													</td>       
												   </tr>
													<tr>
														<td align="center" onclick="addRow('captcha')" class="field_buttons" id="table_captcha">
															<img src="<?php echo WD_FMC_URL; ?>/images/captcha.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_captcha">
															<div>Captcha</div>
														</td>
														<td align="center" onclick="addRow('button')" id="table_button" class="field_buttons">
															<img src="<?php echo WD_FMC_URL; ?>/images/button.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" style="margin:5px" id="img_button">
															<div>Button</div>
														</td>			
													</tr>
												</tbody>
											</table>
										</td>
										<td width="40%" height="100%" align="left">
											<div id="edit_table"></div>
										</td>
										<td align="center" valign="top" style="background: url("<?php echo WD_FMC_URL . '/images/border2.png'; ?>") repeat-y;">&nbsp;</td>
										<td style="padding:15px;">
											<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%" >
												<tr>
													<td align="right">
														<input type="radio" value="end" name="el_pos" checked="checked" id="pos_end" onclick="Disable()"/>
														At The End
														<input type="radio" value="begin" name="el_pos" id="pos_begin" onclick="Disable()"/>
														At The Beginning
														<input type="radio" value="before" name="el_pos" id="pos_before" onclick="Enable()"/>
														Before
														<select style="width: 100px; margin-left: 5px;" id="sel_el_pos" onclick="change_before()" disabled="disabled"></select>
														<br>
														<button class="fm-button field-save-button small" onclick="add(0, false); return false;">
															Save
															<span></span>
														</button>
														<button class="fm-button cancel-button small" onclick="close_window(); return false;">
															Cancel
															<span></span>
														</button>
														<hr style="margin-bottom:10px" />
													</td>
												</tr>
												<tr height="100%" valign="top">
													<td id="show_table"></td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
					<input type="hidden" id="old" />
					<input type="hidden" id="old_selected" />
					<input type="hidden" id="element_type" />
					<input type="hidden" id="editing_id" />
					<input type="hidden" value="<?php echo WD_FMC_URL; ?>" id="form_plugins_url" />
					<div id="main_editor" style="position: fixed; display: none; z-index: 140;">
						<?php if (user_can_richedit()) {
							wp_editor('', 'form_maker_editor', array('teeny' => FALSE, 'textarea_name' => 'form_maker_editor', 'media_buttons' => FALSE, 'textarea_rows' => 5));
						}
						else { ?>
							<textarea name="form_maker_editor" id="form_maker_editor" cols="40" rows="5" style="width: 440px; height: 350px;" class="mce_editable" aria-hidden="true"></textarea>
							<?php
						}
						?>
					</div>
				</div>
					<?php if (!function_exists('the_editor')) { ?>
						<iframe id="tinymce" style="display: none;"></iframe>
					<?php } ?>
				
				<div class="fm-edit-content">		
					<div class="fm-drag-and-drop">
						<div>
							<label for="enable_sortable">Enable Drag & Drop</label>
							<button name="sortable" id="enable_sortable" class="fm-checkbox-radio-button <?php echo $row->sortable == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="enable_drag(this); return false;" value="<?php echo $row->sortable; ?>">
								<span></span>
							</button>	
							<input type="hidden" name="sortable" id="sortable_hidden" value="<?php echo $row->sortable; ?>"/>					
						</div>
						<div>
							You can use drag and drop to move the fields up/down for the change of the order and left/right for creating columns within the form.
						</div>
					</div>
					<fieldset>
						<legend></legend>
						<?php if ($id) { ?>
							<div style="margin: 8px; display: table; width: 100%;" id="page_bar">
								<div id="page_navigation" style="display: table-row;">
									<div align="center" id="pages" show_title="<?php echo $row->show_title; ?>" show_numbers="<?php echo $row->show_numbers; ?>" type="<?php echo $row->pagination; ?>" style="display: table-cell;  width:90%;"></div>
									<div align="left" id="edit_page_navigation" style="display: table-cell; vertical-align: middle;"></div>
								</div>
							</div>
							<div id="take" class="main">
								<?php echo $row->form_front; ?>
							</div>
						<?php } else { ?>
							<div style="margin:8px; display:table; width:100%"  id="page_bar">
								<div id="page_navigation" style="display:table-row">
									<div align="center" id="pages" show_title="false" show_numbers="true" type="none" style="display:table-cell;  width:90%"></div>
									<div align="left" id="edit_page_navigation" style="display:table-cell; vertical-align: middle;"></div>
								</div>
							</div>
							<div id="take" class="main">
								<div class="wdform-page-and-images" style="display:table; border-top:0px solid black;">
									<div id="form_id_tempform_view1" class="wdform_page" page_title="Untitled page" next_title="Next" next_type="text" next_class="wdform-page-button" next_checkable="false" previous_title="Previous" previous_type="text" previous_class="wdform-page-button" previous_checkable="false">
										<div class="wdform_section">
											<div class="wdform_column"></div>
										</div>
										<div valign="top" class="wdform_footer" style="width: 100%;">
											<div style="width: 100%;">
												<div style="width: 100%; display: table; padding-top:10px;">
													<div style="display: table-row-group;">
														<div id="form_id_temppage_nav1" style="display: table-row;"></div>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div id="form_id_tempform_view_img1" style="float: right;">
										<div>
											<img src="<?php echo WD_FMC_URL . '/images/minus.png?ver='. get_option("wd_form_maker_version"); ?>" title="Show or hide the page" class="page_toolbar" onClick="show_or_hide('1')" onMouseOver="chnage_icons_src(this,'minus')" onmouseout="chnage_icons_src(this,'minus')" id="show_page_img_1"/>
											<img src="<?php echo WD_FMC_URL . '/images/page_delete.png?ver='. get_option("wd_form_maker_version"); ?>" title="Delete the page" class="page_toolbar" onClick="remove_page('1')" onMouseOver="chnage_icons_src(this,'page_delete')" onmouseout="chnage_icons_src(this,'page_delete')"/>
											<img src="<?php echo WD_FMC_URL . '/images/page_delete_all.png?ver='. get_option("wd_form_maker_version"); ?>" title="Delete the page with fields" class="page_toolbar" onClick="remove_page_all('1')" onMouseOver="chnage_icons_src(this,'page_delete_all')" onmouseout="chnage_icons_src(this,'page_delete_all')"/>
											<img src="<?php echo WD_FMC_URL . '/images/page_edit.png?ver='. get_option("wd_form_maker_version"); ?>" title="Edit the page" class="page_toolbar" onClick="edit_page_break('1')" onMouseOver="chnage_icons_src(this,'page_edit')"  onmouseout="chnage_icons_src(this,'page_edit')"/>
										</div>
									</div>
								</div>
							</div>
						<?php } ?>
					</fieldset>
				</div>
				<input type="hidden" name="form_front" id="form_front" />
				<input type="hidden" name="form_fields" id="form_fields" />
				<input type="hidden" name="pagination" id="pagination" />
				<input type="hidden" name="show_title" id="show_title" />
				<input type="hidden" name="show_numbers" id="show_numbers" />
				<input type="hidden" name="public_key" id="public_key" />
				<input type="hidden" name="private_key" id="private_key" />
				<input type="hidden" name="recaptcha_theme" id="recaptcha_theme" />
				<input type="hidden" id="label_order" name="label_order" value="<?php echo $row->label_order; ?>" />
				<input type="hidden" id="label_order_current" name="label_order_current" value="<?php echo $row->label_order_current; ?>" />  
				<input type="hidden" name="counter" id="counter" value="<?php echo $row->counter; ?>" />
				<input type="hidden" id="araqel" value="0" />
				<input type="hidden" name="backup_id" id="backup_id" value="<?php echo $row->backup_id;?>">
				
				<?php if ($id) { ?>
				<script type="text/javascript">
					function set_preview() {
						jQuery("#preview_form").attr("onclick", "tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php')); ?>&test_theme=" + jQuery('#theme').val() + "&width=1000&height=500&TB_iframe=1'); return false;");
						jQuery("#edit_css").attr("onclick", "tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php')); ?>&id=" + jQuery('#theme').val() + "&width=800&height=500&TB_iframe=1'); return false;");
					}
					function formOnload() {
						for (t = 0; t < <?php echo $row->counter; ?>; t++) {
							if (document.getElementById(t + "_typeform_id_temp")) {
								if (document.getElementById(t + "_typeform_id_temp").value == "type_map" || document.getElementById(t + "_typeform_id_temp").value == "type_mark_map") {
									if_gmap_init(t);
									for (q = 0; q < 20; q++) {
										if (document.getElementById(t + "_elementform_id_temp").getAttribute("long" + q)) {
											w_long = parseFloat(document.getElementById(t + "_elementform_id_temp").getAttribute("long" + q));
											w_lat = parseFloat(document.getElementById(t + "_elementform_id_temp").getAttribute("lat" + q));
											w_info = parseFloat(document.getElementById(t + "_elementform_id_temp").getAttribute("info" + q));
											add_marker_on_map(t, q, w_long, w_lat, w_info, false);
										}
									}
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_date") {
									// Calendar.setup({
									  // inputField:t + "_elementform_id_temp",
									  // ifFormat:document.getElementById(t + "_buttonform_id_temp").getAttribute('format'),
									  // button:t + "_buttonform_id_temp",
									  // align:"Tl",
									  // singleClick:true,
									  // firstDay:0
									// });
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_name") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("#" + myu + "_mini_label_first").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var first = "<input type='text' id='first' class='first' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(first);
												jQuery("input.first").focus();
												jQuery("input.first").blur(function () {
													var id_for_blur = document.getElementById('first').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_first").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_last").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var last = "<input type='text' id='last' class='last'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(last);
												jQuery("input.last").focus();
												jQuery("input.last").blur(function () {
													var id_for_blur = document.getElementById('last').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_last").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_title").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var title_ = "<input type='text' id='title_' class='title_'  style='outline:none; border:none; background:none; width:50px;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(title_);
												jQuery("input.title_").focus();
												jQuery("input.title_").blur(function () {
													var id_for_blur = document.getElementById('title_').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_title").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_middle").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var middle = "<input type='text' id='middle' class='middle'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(middle);
												jQuery("input.middle").focus();
												jQuery("input.middle").blur(function () {
													var id_for_blur = document.getElementById('middle').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_middle").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_phone") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("label#" + myu + "_mini_label_area_code").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var area_code = "<input type='text' id='area_code' class='area_code' size='10' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(area_code);
												jQuery("input.area_code").focus();
												jQuery("input.area_code").blur(function () {
													var id_for_blur = document.getElementById('area_code').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_area_code").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_phone_number").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var phone_number = "<input type='text' id='phone_number' class='phone_number'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(phone_number);
												jQuery("input.phone_number").focus();
												jQuery("input.phone_number").blur(function () {
													var id_for_blur = document.getElementById('phone_number').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_phone_number").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_date_fields") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("label#" + myu + "_day_label").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var day = "<input type='text' id='day' class='day' size='8' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(day);
												jQuery("input.day").focus();
												jQuery("input.day").blur(function () {
													var id_for_blur = document.getElementById('day').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_day_label").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_month_label").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var month = "<input type='text' id='month' class='month' size='8' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(month);
												jQuery("input.month").focus();
												jQuery("input.month").blur(function () {
													var id_for_blur = document.getElementById('month').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_month_label").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_year_label").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var year = "<input type='text' id='year' class='year' size='8' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(year);
												jQuery("input.year").focus();
												jQuery("input.year").blur(function () {
													var id_for_blur = document.getElementById('year').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_year_label").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_time") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("label#" + myu + "_mini_label_hh").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var hh = "<input type='text' id='hh' class='hh' size='4' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(hh);
												jQuery("input.hh").focus();
												jQuery("input.hh").blur(function () {
													var id_for_blur = document.getElementById('hh').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_hh").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_mm").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var mm = "<input type='text' id='mm' class='mm' size='4' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(mm);
												jQuery("input.mm").focus();
												jQuery("input.mm").blur(function () {
													var id_for_blur = document.getElementById('mm').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_mm").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_ss").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var ss = "<input type='text' id='ss' class='ss' size='4' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(ss);
												jQuery("input.ss").focus();
												jQuery("input.ss").blur(function () {
													var id_for_blur = document.getElementById('ss').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_ss").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_am_pm").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var am_pm = "<input type='text' id='am_pm' class='am_pm' size='4' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(am_pm);
												jQuery("input.am_pm").focus();
												jQuery("input.am_pm").blur(function () {
													var id_for_blur = document.getElementById('am_pm').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_am_pm").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_paypal_price") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("#" + myu + "_mini_label_dollars").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var dollars = "<input type='text' id='dollars' class='dollars' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(dollars);
												jQuery("input.dollars").focus();
												jQuery("input.dollars").blur(function () {
													var id_for_blur = document.getElementById('dollars').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_dollars").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_cents").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var cents = "<input type='text' id='cents' class='cents'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(cents);
												jQuery("input.cents").focus();
												jQuery("input.cents").blur(function () {
													var id_for_blur = document.getElementById('cents').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_cents").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_address") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("label#" + myu + "_mini_label_street1").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var street1 = "<input type='text' id='street1' class='street1' style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(street1);
												jQuery("input.street1").focus();
												jQuery("input.street1").blur(function () {
													var id_for_blur = document.getElementById('street1').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_street1").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_street2").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var street2 = "<input type='text' id='street2' class='street2'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(street2);
												jQuery("input.street2").focus();
												jQuery("input.street2").blur(function () {
													var id_for_blur = document.getElementById('street2').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_street2").text(value);
											  });
											}
										});
										jQuery("label#" + myu + "_mini_label_city").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var city = "<input type='text' id='city' class='city'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(city);
												jQuery("input.city").focus();
												jQuery("input.city").blur(function () {
													var id_for_blur = document.getElementById('city').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_city").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_state").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var state = "<input type='text' id='state' class='state'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(state);
												jQuery("input.state").focus();
												jQuery("input.state").blur(function () {
													var id_for_blur = document.getElementById('state').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_state").text(value);
											  });
											}
										});
										jQuery("label#" + myu + "_mini_label_postal").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var postal = "<input type='text' id='postal' class='postal'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(postal);
												jQuery("input.postal").focus();
												jQuery("input.postal").blur(function () {
													var id_for_blur = document.getElementById('postal').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_postal").text(value);
												});
											}
										});
										jQuery("label#" + myu + "_mini_label_country").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var country = "<input type='country' id='country' class='country'  style='outline:none; border:none; background:none;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(country);
												jQuery("input.country").focus();
												jQuery("input.country").blur(function () {
													var id_for_blur = document.getElementById('country').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_country").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_scale_rating") {
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("#" + myu + "_mini_label_worst").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var worst = "<input type='text' id='worst' class='worst' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(worst);
												jQuery("input.worst").focus();
												jQuery("input.worst").blur(function () {
													var id_for_blur = document.getElementById('worst').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_worst").text(value);
											  });
											}
										});
										jQuery("label#" + myu + "_mini_label_best").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var best = "<input type='text' id='best' class='best' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(best);
												jQuery("input.best").focus();
												jQuery("input.best").blur(function () {
													var id_for_blur = document.getElementById('best').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_best").text(value);
												});
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_spinner") {
									var spinner_value = document.getElementById(t + "_elementform_id_temp").value;
									var spinner_min_value = document.getElementById(t + "_min_valueform_id_temp").value;
									var spinner_max_value = document.getElementById(t + "_max_valueform_id_temp").value;
									var spinner_step = document.getElementById(t + "_stepform_id_temp").value;
									jQuery("#" + t + "_elementform_id_temp")[0].spin = null;
									spinner = jQuery("#" + t + "_elementform_id_temp").spinner();
									spinner.spinner("value", spinner_value);
									jQuery("#" + t + "_elementform_id_temp").spinner({ min:spinner_min_value});
									jQuery("#" + t + "_elementform_id_temp").spinner({ max:spinner_max_value});
									jQuery("#" + t + "_elementform_id_temp").spinner({ step:spinner_step});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_slider") {
									var slider_value = document.getElementById(t + "_slider_valueform_id_temp").value;
									var slider_min_value = document.getElementById(t + "_slider_min_valueform_id_temp").value;
									var slider_max_value = document.getElementById(t + "_slider_max_valueform_id_temp").value;
									var slider_element_value = document.getElementById(t + "_element_valueform_id_temp");
									var slider_value_save = document.getElementById(t + "_slider_valueform_id_temp");
									jQuery("#" + t + "_elementform_id_temp")[0].slide = null;
									jQuery(function () {
										jQuery("#" + t + "_elementform_id_temp").slider({
											range:"min",
											value:eval(slider_value),
											min:eval(slider_min_value),
											max:eval(slider_max_value),
											slide:function (event, ui) {
												slider_element_value.innerHTML = "" + ui.value;
												slider_value_save.value = "" + ui.value;
											}
										});
									});
								}
								else if (document.getElementById(t + "_typeform_id_temp").value == "type_range") {
									var spinner_value0 = document.getElementById(t + "_elementform_id_temp0").value;
									var spinner_step = document.getElementById(t + "_range_stepform_id_temp").value;
									jQuery("#" + t + "_elementform_id_temp0")[0].spin = null;
									jQuery("#" + t + "_elementform_id_temp1")[0].spin = null;
									spinner0 = jQuery("#" + t + "_elementform_id_temp0").spinner();
									spinner0.spinner("value", spinner_value0);
									jQuery("#" + t + "_elementform_id_temp0").spinner({ step:spinner_step});
									var spinner_value1 = document.getElementById(t + "_elementform_id_temp1").value;
									spinner1 = jQuery("#" + t + "_elementform_id_temp1").spinner();
									spinner1.spinner("value", spinner_value1);
									jQuery("#" + t + "_elementform_id_temp1").spinner({ step:spinner_step});
									var myu = t;
									jQuery(document).ready(function () {
										jQuery("#" + myu + "_mini_label_from").click(function () {
											if (jQuery(this).children('input').length == 0) {
												var from = "<input type='text' id='from' class='from' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\"" + jQuery(this).text() + "\">";
												jQuery(this).html(from);
												jQuery("input.from").focus();
												jQuery("input.from").blur(function () {
													var id_for_blur = document.getElementById('from').parentNode.id.split('_');
													var value = jQuery(this).val();
													jQuery("#" + id_for_blur[0] + "_mini_label_from").text(value);
												});
											}
									});
									jQuery("label#" + myu + "_mini_label_to").click(function () {
										if (jQuery(this).children('input').length == 0) {
											var to = "<input type='text' id='to' class='to' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\"" + jQuery(this).text() + "\">";
											jQuery(this).html(to);
											jQuery("input.to").focus();
											jQuery("input.to").blur(function () {
												var id_for_blur = document.getElementById('to').parentNode.id.split('_');
												var value = jQuery(this).val();
												jQuery("#" + id_for_blur[0] + "_mini_label_to").text(value);
											});
										}
									});
								});
							}
						}
					}
						
						remove_whitespace(document.getElementById('take'));
						form_view = 1;
						form_view_count = 0;
						
						for (i = 1; i <= 30; i++) {
							if (document.getElementById('form_id_tempform_view' + i)) {
								form_view_count++;
								form_view_max = i;
								tbody_img = document.createElement('div');
								tbody_img.setAttribute('id', 'form_id_tempform_view_img' + i);
								tbody_img.style.cssText = "float:right";
								tr_img = document.createElement('div');
								var img = document.createElement('img');
									img.setAttribute('src', '<?php echo WD_FMC_URL; ?>/images/minus.png?ver=<?php echo get_option("wd_form_maker_version"); ?>');
									img.setAttribute('title', 'Show or hide the page');
									img.setAttribute("class", "page_toolbar");
									img.setAttribute('id', 'show_page_img_' + i);
									img.setAttribute('onClick', 'show_or_hide("' + i + '")');
									img.setAttribute("onmouseover", 'chnage_icons_src(this,"minus")');
									img.setAttribute("onmouseout", 'chnage_icons_src(this,"minus")');
								var img_X = document.createElement("img");
									img_X.setAttribute("src", "<?php echo WD_FMC_URL; ?>/images/page_delete.png?ver=<?php echo get_option("wd_form_maker_version"); ?>");
									img_X.setAttribute('title', 'Delete the page');
									img_X.setAttribute("class", "page_toolbar");
									img_X.setAttribute("onclick", 'remove_page("' + i + '")');
									img_X.setAttribute("onmouseover", 'chnage_icons_src(this,"page_delete")');
									img_X.setAttribute("onmouseout", 'chnage_icons_src(this,"page_delete")');
								var img_X_all = document.createElement("img");
									img_X_all.setAttribute("src", "<?php echo WD_FMC_URL; ?>/images/page_delete_all.png?ver=<?php echo get_option("wd_form_maker_version"); ?>");
									img_X_all.setAttribute('title', 'Delete the page with fields');
									img_X_all.setAttribute("class", "page_toolbar");
									img_X_all.setAttribute("onclick", 'remove_page_all("' + i + '")');
									img_X_all.setAttribute("onmouseover", 'chnage_icons_src(this,"page_delete_all")');
									img_X_all.setAttribute("onmouseout", 'chnage_icons_src(this,"page_delete_all")');
								var img_EDIT = document.createElement("img");
									img_EDIT.setAttribute("src", "<?php echo WD_FMC_URL; ?>/images/page_edit.png?ver=<?php echo get_option("wd_form_maker_version"); ?>");
									img_EDIT.setAttribute('title', 'Edit the page');
									img_EDIT.setAttribute("class", "page_toolbar");
									img_EDIT.setAttribute("onclick", 'edit_page_break("' + i + '")');
									img_EDIT.setAttribute("onmouseover", 'chnage_icons_src(this,"page_edit")');
									img_EDIT.setAttribute("onmouseout", 'chnage_icons_src(this,"page_edit")');
								tr_img.appendChild(img);
								tr_img.appendChild(img_X);
								tr_img.appendChild(img_X_all);
								tr_img.appendChild(img_EDIT);
								tbody_img.appendChild(tr_img);
								document.getElementById('form_id_tempform_view' + i).parentNode.appendChild(tbody_img);
							}
						}
						
						if (form_view_count > 1) {
							for (i = 1; i <= form_view_max; i++) {
								if (document.getElementById('form_id_tempform_view' + i)) {
									first_form_view = i;
									break;
								}
							}
							form_view = form_view_max;
							need_enable = false;
							generate_page_nav(first_form_view);
							var img_EDIT = document.createElement("img");
								img_EDIT.setAttribute("src", "<?php echo WD_FMC_URL . '/images/edit.png?ver='.get_option("wd_form_maker_version"); ?>");
								img_EDIT.style.cssText = "margin-left:40px; cursor:pointer";
								img_EDIT.setAttribute("onclick", 'el_page_navigation()');
							var td_EDIT = document.getElementById("edit_page_navigation");
								td_EDIT.appendChild(img_EDIT);
							document.getElementById('page_navigation').appendChild(td_EDIT);
						}
						document.getElementById('araqel').value = 1;
					}
					jQuery(window).load(function () {
						formOnload();
					});
					jQuery(function() {
						jQuery('.wdform_section .wdform_column:last-child').each(function() {
							jQuery(this).parent().append(jQuery('<div></div>').addClass("wdform_column"));		
						});
							
						sortable_columns();
						if(<?php echo $row->sortable ?>==1) {
							jQuery( ".wdform_arrows" ).hide();
							all_sortable_events();
						}
						else
							jQuery('.wdform_column').sortable( "disable" );	
						  
					});
				</script>
				<?php
				} else { ?>
					<script type="text/javascript">
						jQuery(function() {
							jQuery('.wdform_section .wdform_column:last-child').each(function() {
								jQuery(this).parent().append(jQuery('<div></div>').addClass("wdform_column"));		
							});
							sortable_columns();
							all_sortable_events();
						});
					</script>
				<?php } ?>
			<input type="hidden" name="option" value="com_formmaker" />
			<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
			<input type="hidden" name="cid[]" value="<?php echo $row->id; ?>" />
			<input type="hidden" id="task" name="task" value=""/>
			<input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
		</form>
		<?php
	}

  public function edit_old($id) {
    // header("X-XSS-Protection: 0");
    $row = $this->model->get_row_data($id);
    $themes = $this->model->get_theme_rows_data('old');
    $labels = array();
    $label_id = array();
    $label_order_original = array();
    $label_type = array();
    $label_all = explode('#****#', $row->label_order);
    $label_all = array_slice($label_all, 0, count($label_all) - 1);
    foreach ($label_all as $key => $label_each) {
      $label_id_each = explode('#**id**#', $label_each);
      array_push($label_id, $label_id_each[0]);
      $label_oder_each = explode('#**label**#', $label_id_each[1]);
      array_push($label_order_original, addslashes($label_oder_each[0]));
      array_push($label_type, $label_oder_each[1]);
    }
    $labels['id'] = '"' . implode('","', $label_id) . '"';
    $labels['label'] = '"' . implode('","', $label_order_original) . '"';
    $labels['type'] = '"' . implode('","', $label_type) . '"';

    $page_title = (($id != 0) ? 'Edit form ' . $row->title : 'Create new form');
    ?>
    <script type="text/javascript">
      var plugin_url = "<?php echo WD_FMC_URL; ?>";
    </script>
    <script src="<?php echo WD_FMC_URL . '/js/formmaker_free.js'; ?>?ver=<?php echo get_option("wd_form_maker_version"); ?>" type="text/javascript"></script>
    <script type="text/javascript">
      function submitbutton() {
        if (!document.getElementById('araqel') || (document.getElementById('araqel').value == '0')) {
          alert('Please wait while page loading.');
          return false;
        }
        tox = '';
        l_id_array = [<?php echo $labels['id']?>];
        l_label_array = [<?php echo $labels['label']?>];
        l_type_array = [<?php echo $labels['type']?>];
        l_id_removed = [];      
        for (x=0; x< l_id_array.length; x++) {
          l_id_removed[l_id_array[x]]=true;
        }
        for (t=1;t<=form_view_max;t++) {
          if (document.getElementById('form_id_tempform_view'+t)) {
            form_view_element=document.getElementById('form_id_tempform_view'+t);		
            n=form_view_element.childNodes.length-2;
            for(q=0;q<=n;q++) {
              if (form_view_element.childNodes[q].nodeType!=3) {
                if (!form_view_element.childNodes[q].id) {
                  GLOBAL_tr=form_view_element.childNodes[q];
                  for (x=0; x < GLOBAL_tr.firstChild.childNodes.length; x++) {
                    table=GLOBAL_tr.firstChild.childNodes[x];
                    tbody=table.firstChild;
                    for (y=0; y < tbody.childNodes.length; y++) {
                      is_in_old=false;
                      tr=tbody.childNodes[y];
                      l_id=tr.id;
                      l_label=document.getElementById( tr.id+'_element_labelform_id_temp').innerHTML;
                      l_label = l_label.replace(/(\r\n|\n|\r)/gm," ");
                      l_type=tr.getAttribute('type');
                      for (z = 0; z < l_id_array.length; z++) {
                        if (l_id_array[z] == l_id) {
                          if (l_type_array[z] == "type_address") {
                            if (document.getElementById(l_id + "_mini_label_street1")) {
                              l_id_removed[l_id_array[z]] = false;
                            }
                            if (document.getElementById(l_id+"_mini_label_street2")) {
                              l_id_removed[parseInt(l_id_array[z]) + 1] = false;
                            }
                            if (document.getElementById(l_id+"_mini_label_city")) {
                              l_id_removed[parseInt(l_id_array[z]) + 2] = false;	
                            }
                            if (document.getElementById(l_id+"_mini_label_state")) {
                              l_id_removed[parseInt(l_id_array[z]) + 3] = false;
                            }
                            if (document.getElementById(l_id+"_mini_label_postal")) {
                              l_id_removed[parseInt(l_id_array[z]) + 4] = false;
                            }
                            if (document.getElementById(l_id+"_mini_label_country")) {
                              l_id_removed[parseInt(l_id_array[z]) + 5] = false;	
                            }
                            z = z + 5;
                          }
                          else {
                            l_id_removed[l_id] = false;
                          }
                        }
                      }
                      if (tr.getAttribute('type')=="type_address") {
                        addr_id=parseInt(tr.id);
                        id_for_country= addr_id;
                        if(document.getElementById(id_for_country+"_mini_label_street1"))
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_street1").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#';addr_id++; 
                        if(document.getElementById(id_for_country+"_mini_label_street2"))
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_street2").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#';addr_id++; 
                        if(document.getElementById(id_for_country+"_mini_label_city"))
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_city").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#';	addr_id++; 
                        if(document.getElementById(id_for_country+"_mini_label_state"))
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_state").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#';	addr_id++;
                        if(document.getElementById(id_for_country+"_mini_label_postal"))									
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_postal").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#';	addr_id++; 
                        if(document.getElementById(id_for_country+"_mini_label_country"))									
                          tox=tox+addr_id+'#**id**#'+document.getElementById(id_for_country+"_mini_label_country").innerHTML+'#**label**#'+tr.getAttribute('type')+'#****#'; 
                      }
                      else {
                        tox = tox+l_id+'#**id**#'+l_label+'#**label**#'+l_type+'#****#';
                      }
                    }
                  }
                }
              }
            }
          }	
        }
        document.getElementById('label_order_current').value = tox;
        for (x = 0; x < l_id_array.length; x++) {
          if (l_id_removed[l_id_array[x]]) {
            tox = tox + l_id_array[x] + '#**id**#' + l_label_array[x] + '#**label**#' + l_type_array[x] + '#****#';
          }
        }
        document.getElementById('label_order').value = tox;
        refresh_old();
        document.getElementById('pagination').value=document.getElementById('pages').getAttribute("type");
        document.getElementById('show_title').value=document.getElementById('pages').getAttribute("show_title");
        document.getElementById('show_numbers').value=document.getElementById('pages').getAttribute("show_numbers");
        return true;
      }

      gen = <?php echo (($id != 0) ? $row->counter : 1); ?>;

      function enable() {
        alltypes = Array('customHTML', 'text', 'checkbox', 'radio', 'time_and_date', 'select', 'file_upload', 'captcha', 'map', 'button', 'page_break', 'section_break', 'paypal', 'survey');
        for (x = 0; x < 14; x++) {
          document.getElementById('img_' + alltypes[x]).src = "<?php echo WD_FMC_URL . '/images/'; ?>" + alltypes[x] + ".png?ver=<?php echo get_option("wd_form_maker_version"); ?>";
        }
        if (document.getElementById('formMakerDiv').style.display == 'block') {
          jQuery('#formMakerDiv').slideToggle(200);
        }
        else {
          jQuery('#formMakerDiv').slideToggle(400);
        }
        
        if (document.getElementById('formMakerDiv1').style.display == 'block') {
          jQuery('#formMakerDiv1').slideToggle(200);
        }
        else {
          jQuery('#formMakerDiv1').slideToggle(400);
        }
        document.getElementById('when_edit').style.display = 'none';
      }

      function enable2() {
        alltypes = Array('customHTML', 'text', 'checkbox', 'radio', 'time_and_date', 'select', 'file_upload', 'captcha', 'map', 'button', 'page_break', 'section_break', 'paypal', 'survey');
        for (x = 0; x < 14; x++) {
          document.getElementById('img_' + alltypes[x]).src = "<?php echo WD_FMC_URL . '/images/'; ?>" + alltypes[x] + ".png?ver=<?php echo get_option("wd_form_maker_version"); ?>";
        }
        if (document.getElementById('formMakerDiv').style.display == 'block') {
          jQuery('#formMakerDiv').slideToggle(200);
        }
        else {
          jQuery('#formMakerDiv').slideToggle(400);
        }
        
        if (document.getElementById('formMakerDiv1').style.display == 'block') {
          jQuery('#formMakerDiv1').slideToggle(200);
        }
        else {
          jQuery('#formMakerDiv1').slideToggle(400);
        }
        document.getElementById('when_edit').style.display = 'block';
        if (document.getElementById('field_types').offsetWidth) {
          document.getElementById('when_edit').style.width = document.getElementById('field_types').offsetWidth + 'px';
        }
        if (document.getElementById('field_types').offsetHeight) {
          document.getElementById('when_edit').style.height = document.getElementById('field_types').offsetHeight + 'px';
        }
      }
    </script>
<div style="font-size: 14px; font-weight: bold;">
        This section allows you to add fields to your form.
        <a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-4.html">Read More in User Manual</a>
      </div>
    <form class="wrap" id="manage_form" method="post" action="admin.php?page=manage_fmc" style="width:99%;">
      <?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
	  <div class="fm-page-header">
			<!-- <div class="fm-page-title">
				<?php echo $page_title; ?>
			</div> -->
			<div style="float:left;">
				<div class="fm-logo-edit-page"></div>
				<div class="fm-title-edit-page">Form</br>Maker</div>
			</div>
			<div class="fm-page-actions">
				<button class="fm-button form-options-button medium" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'form_options_old');">
					<span></span>
					Form Options
				</button>
				<div style="height:40px; border-right: 1px solid #848484; display: inline-block; width: 5px; vertical-align: bottom; margin-right: 5px;"></div>				
				<?php if ($id) { ?>
					<button class="fm-button save-as-copy-button medium" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'save_as_copy_old');">
						<span></span>
						Save as Copy
					</button>
				<?php } ?>
				<button class="fm-button save-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'save_old');">
					<span></span>
					Save
				</button>
				<button class="fm-button apply-button small" onclick="if (fm_check_required('title', 'Form title') || !submitbutton()) {return false;}; fm_set_input_value('task', 'apply_old');">
					<span></span>
					Apply
				</button>
				<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', 'cancel');">
					<span></span>
					Cancel
				</button>
			</div>
			<div class="fm-clear"></div>
		</div>
		<div class="fm-theme-banner">
			<div style="float:left;">
				<span style="">Form title:&nbsp;</span>
				<input id="title" name="title" value="<?php echo $row->title; ?>"/>
			</div>
			<div style="float:right;">
				<button class="fm-button add-new-button large" onclick="enable(); Enable(); return false;">
					Add a New Field
					<span></span>
				</button>
			</div>	
		</div>	
		<div class="fm-clear"></div>
		<div id="formMakerDiv" onclick="close_window()"></div>
		<div id="formMakerDiv1" style="padding-top: 20px;" align="center">
			<table border="0" width="100%" cellpadding="0" cellspacing="0" height="100%" class="formMakerDiv1_table">
				<tr>
					<td style="padding:0px">
					<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                <tr valign="top">
                  <td width="15%" height="100%" style="border-right: dotted black 1px;" id="field_types">
                    <div id="when_edit" style="display: none;"></div>
                    <table border="0" cellpadding="0" cellspacing="3" width="100%">
                      <tr>
                        <td align="center" onClick="addRow('customHTML')" style="cursor:pointer" id="table_editor"  class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/customHTML.png'; ?>" style="margin:5px" id="img_customHTML"/>
                        </td>
                        <td align="center" onClick="addRow('text')" style="cursor:pointer" id="table_text" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/text.png'; ?>" style="margin:5px" id="img_text"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('time_and_date')" style="cursor:pointer" id="table_time_and_date" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/time_and_date.png'; ?>" style="margin:5px" id="img_time_and_date"/>
                        </td>
                        <td align="center" onClick="addRow('select')" style="cursor:pointer" id="table_select" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/select.png'; ?>" style="margin:5px" id="img_select"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('checkbox')" style="cursor:pointer" id="table_checkbox" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/checkbox.png'; ?>" style="margin:5px" id="img_checkbox"/>
                        </td>
                        <td align="center" onClick="addRow('radio')" style="cursor:pointer" id="table_radio" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/radio.png'; ?>" style="margin:5px" id="img_radio"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('file_upload')" style="cursor:pointer" id="table_file_upload" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/file_upload.png'; ?>" style="margin:5px" id="img_file_upload"/>
                        </td>
                        <td align="center" onClick="addRow('captcha')" style="cursor:pointer" id="table_captcha" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/captcha.png'; ?>" style="margin:5px" id="img_captcha"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('page_break')" style="cursor:pointer" id="table_page_break" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/page_break.png'; ?>" style="margin:5px" id="img_page_break"/>
                        </td>
                        <td align="center" onClick="addRow('section_break')" style="cursor:pointer" id="table_section_break" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/section_break.png'; ?>" style="margin:5px" id="img_section_break"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('map')" style="cursor:pointer" id="table_map" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/map.png'; ?>" style="margin:5px" id="img_map"/>
                        </td>
                        <td align="center" onClick="addRow('paypal')" id="table_paypal" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/paypal.png'; ?>" style="margin:5px" id="img_paypal"/>
                        </td>
                      </tr>
                      <tr>
                        <td align="center" onClick="addRow('survey')" class="field_buttons" id="table_survey">
                          <img src="<?php echo WD_FMC_URL . '/images/survey.png'; ?>" style="margin:5px" id="img_survey"/>
                        </td>
                        <td align="center" onClick="addRow('button')" id="table_button" class="field_buttons">
                          <img src="<?php echo WD_FMC_URL . '/images/button.png'; ?>" style="margin:5px" id="img_button"/>
                        </td>
                    </tr>
                    </table>
                  </td>
                  <td width="35%" height="100%" align="left">
                    <div id="edit_table" style="padding:0px; overflow-y:scroll; height:575px"></div>
                  </td>
                  <td align="center" valign="top" style="background: url("<?php echo WD_FMC_URL . '/images/border2.png'; ?>") repeat-y;">&nbsp;</td>
                  <td style="padding:15px">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                      <tr>
                        <td align="right">
                          <input type="radio" value="end" name="el_pos" checked="checked" id="pos_end" onclick="Disable()"/>
                          At The End
                          <input type="radio" value="begin" name="el_pos" id="pos_begin" onclick="Disable()"/>
                          At The Beginning
                          <input type="radio" value="before" name="el_pos" id="pos_before" onclick="Enable()"/>
                          Before
                          <select style="width: 100px; margin-left: 5px;" id="sel_el_pos" disabled="disabled"></select>
						  <button class="fm-button field-save-button small" onclick="add(0, false); return false;">
							Save
							<span></span>
						</button>
						<button class="fm-button cancel-button small" onclick="close_window(); return false;">
							Cancel
							<span></span>
						</button>
                          <hr style=" margin-bottom:10px" />
                        </td>
                      </tr>
                      <tr height="100%" valign="top">
                        <td id="show_table"></td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
        <input type="hidden" id="old" />
        <input type="hidden" id="old_selected" />
        <input type="hidden" id="element_type" />
        <input type="hidden" id="editing_id" />
        <input type="hidden" value="<?php echo WD_FMC_URL; ?>" id="form_plugins_url" />
        <div id="main_editor" style="position: fixed; display: none; z-index: 140;">
          <?php
          if (user_can_richedit()) {
            wp_editor('', 'form_maker_editor', array('teeny' => FALSE, 'textarea_name' => 'form_maker_editor', 'media_buttons' => FALSE, 'textarea_rows' => 5));
          }
          else {
            ?>
            <textarea cols="36" rows="5" id="form_maker_editor" name="form_maker_editor" style="width: 440px; height: 350px; resize: vertical;" class="mce_editable" aria-hidden="true"></textarea>
            <?php
          }
          ?>
        </div>
      </div>
      <?php
      if (!function_exists('the_editor')) {
        ?>
        <iframe id="tinymce" style="display: none;"></iframe>
        <?php
      }
      ?>
      <br />      
      <br />
      <fieldset>
        <legend><h2 style="color: #00aeef;">Form</h2></legend>
        <table width="100%" style="margin:8px">
          <tr id="page_navigation">
            <td align="center" width="90%" id="pages" show_title="<?php echo $row->show_title; ?>" show_numbers="<?php echo $row->show_numbers; ?>" type="<?php echo $row->pagination; ?>"></td>
            <td align="left" id="edit_page_navigation"></td>
          </tr>
        </table>
        <div id="take">
          <?php
          if ($row->form) {
            echo $row->form;
          }
          else {
            ?>
            <table border="0" cellpadding="4" cellspacing="0" class="wdform_table1" style="width: 100%;">
              <tbody id="form_id_tempform_view1" class="wdform_tbody1" page_title="Untitled page" next_title="Next" next_type="button" next_class="wdform_page_button" next_checkable="false" previous_title="Previous" previous_type="button" previous_class="wdform_page_button" previous_checkable="false">
                <tr class="wdform_tr1">
                  <td class="wdform_td1" >
                    <table class="wdform_table2">
                      <tbody class="wdform_tbody2"></tbody>
                    </table>
                  </td>
                </tr>
                <tr class="wdform_footer">
					<td colspan="100" valign="top">
						<table width="100%" style="padding-right:170px">
							<tbody>
								<tr id="form_id_temppage_nav1">
								</tr>
							</tbody>
						</table>
					</td>
                </tr>
                <tbody id="form_id_tempform_view_img1" style="float: right !important;" >
                  <tr>
                    <td width="0%"></td>
                    <td align="right">
                      <img src="<?php echo WD_FMC_URL . '/images/minus.png?ver='. get_option("wd_form_maker_version").''; ?>" title="Show or hide the page" class="page_toolbar" onclick="show_or_hide('1')" onmouseover="chnage_icons_src(this,'minus')" onmouseout="chnage_icons_src(this,'minus')" id="show_page_img_1" />
                    </td>
                    <td>
                      <img src="<?php echo WD_FMC_URL . '/images/page_delete.png?ver='. get_option("wd_form_maker_version").''; ?>" title="Delete the page" class="page_toolbar" onclick="remove_page('1')" onmouseover="chnage_icons_src(this,'page_delete')" onmouseout="chnage_icons_src(this,'page_delete')" />
                    </td>
                    <td>
                      <img src="<?php echo WD_FMC_URL . '/images/page_delete_all.png?ver='. get_option("wd_form_maker_version").''; ?>" title="Delete the page with fields" class="page_toolbar" onclick="remove_page_all('1')" onmouseover="chnage_icons_src(this,'page_delete_all')" onmouseout="chnage_icons_src(this,'page_delete_all')" />
                    </td>
                    <td>
                      <img src="<?php echo WD_FMC_URL . '/images/page_edit.png?ver='. get_option("wd_form_maker_version").''; ?>" title="Edit the page" class="page_toolbar" onclick="edit_page_break('1')" onmouseover="chnage_icons_src(this,'page_edit')" onmouseout="chnage_icons_src(this,'page_edit')" />
                    </td>
                  </tr>
              </tbody>
            </table>
            <?php
          }
          ?>
        </div>
      </fieldset>
      <input type="hidden" name="form" id="form" />
      <input type="hidden" name="form_front" id="form_front" />
      <input type="hidden" name="pagination" id="pagination" />
      <input type="hidden" name="show_title" id="show_title" />
      <input type="hidden" name="show_numbers" id="show_numbers" />
      <input type="hidden" name="public_key" id="public_key" />
      <input type="hidden" name="private_key" id="private_key" />
      <input type="hidden" name="recaptcha_theme" id="recaptcha_theme" />
      <input type="hidden" id="label_order" name="label_order" value="<?php echo $row->label_order; ?>" />
      <input type="hidden" id="label_order_current" name="label_order_current" value="<?php echo $row->label_order_current; ?>" />  
      <input type="hidden" name="counter" id="counter" value="<?php echo $row->counter; ?>" />
      <input type="hidden" id="araqel" value="0" />
      <script type="text/javascript">
        form_view = 1;
        form_view_count = 1;
        form_view_max = 1;
        function formOnload() {
          // Enable maps.
          for (t = 0; t < <?php echo $row->counter;?>; t++)
            if (document.getElementById(t+"_typeform_id_temp")) {
              if (document.getElementById(t+"_typeform_id_temp").value=="type_map" || document.getElementById(t+"_typeform_id_temp").value=="type_mark_map") {
                if_gmap_init(t);
                for (q = 0; q < 20; q++) {
                  if (document.getElementById(t+"_elementform_id_temp").getAttribute("long"+q)) {
                    w_long=parseFloat(document.getElementById(t+"_elementform_id_temp").getAttribute("long"+q));
                    w_lat=parseFloat(document.getElementById(t+"_elementform_id_temp").getAttribute("lat"+q));
                    w_info=parseFloat(document.getElementById(t+"_elementform_id_temp").getAttribute("info"+q));
                    add_marker_on_map(t,q, w_long, w_lat, w_info, false);
                  }
                }
              }
              else
                if (document.getElementById(t+"_typeform_id_temp").value == "type_date") {
                  // Calendar.setup({
                      // inputField: t+"_elementform_id_temp",
                      // ifFormat: document.getElementById(t+"_buttonform_id_temp").getAttribute('format'),
                      // button: t+"_buttonform_id_temp",
                      // align: "Tl",
                      // singleClick: true,
                      // firstDay: 0
                      // });
                }
               else				
        if(document.getElementById(t+"_typeform_id_temp").value=="type_spinner")	{
            var spinner_value = jQuery("#" + t + "_elementform_id_temp").get( "aria-valuenow" );
            var spinner_min_value = document.getElementById(t+"_min_valueform_id_temp").value;
            var spinner_max_value = document.getElementById(t+"_max_valueform_id_temp").value;
              var spinner_step = document.getElementById(t+"_stepform_id_temp").value;
                
               jQuery( "#"+t+"_elementform_id_temp" ).removeClass( "ui-spinner-input" )
          .prop( "disabled", false )
          .removeAttr( "autocomplete" )
          .removeAttr( "role" )
          .removeAttr( "aria-valuemin" )
          .removeAttr( "aria-valuemax" )
          .removeAttr( "aria-valuenow" );
          
          span_ui= document.getElementById(t+"_elementform_id_temp").parentNode;
            span_ui.parentNode.appendChild(document.getElementById(t+"_elementform_id_temp"));
            span_ui.parentNode.removeChild(span_ui);
            
            jQuery("#"+t+"_elementform_id_temp")[0].spin = null;
            
            spinner = jQuery( "#"+t+"_elementform_id_temp" ).spinner();
            spinner.spinner( "value", spinner_value );
            jQuery( "#"+t+"_elementform_id_temp" ).spinner({ min: spinner_min_value});    
                    jQuery( "#"+t+"_elementform_id_temp" ).spinner({ max: spinner_max_value});
                    jQuery( "#"+t+"_elementform_id_temp" ).spinner({ step: spinner_step});
            
        }
            else
          if(document.getElementById(t+"_typeform_id_temp").value=="type_slider")	{
     
            var slider_value = document.getElementById(t+"_slider_valueform_id_temp").value;
            var slider_min_value = document.getElementById(t+"_slider_min_valueform_id_temp").value;
            var slider_max_value = document.getElementById(t+"_slider_max_valueform_id_temp").value;
            
            var slider_element_value = document.getElementById( t+"_element_valueform_id_temp" );
            var slider_value_save = document.getElementById( t+"_slider_valueform_id_temp" );
            
            document.getElementById(t+"_elementform_id_temp").innerHTML = "";
            document.getElementById(t+"_elementform_id_temp").removeAttribute( "class" );
            document.getElementById(t+"_elementform_id_temp").removeAttribute( "aria-disabled" );

             jQuery("#"+t+"_elementform_id_temp")[0].slide = null;	
          
              jQuery(function() {
            jQuery( "#"+t+"_elementform_id_temp").slider({
            range: "min",
            value: eval(slider_value),
            min: eval(slider_min_value),
            max: eval(slider_max_value),
            slide: function( event, ui ) {	
              slider_element_value.innerHTML = "" + ui.value ;
              slider_value_save.value = "" + ui.value; 

        }
      });
      
      
    });	
        
            
        }
        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_range"){
                    var spinner_value0 = jQuery("#" + t+"_elementform_id_temp0").get( "aria-valuenow" );
              var spinner_step = document.getElementById(t+"_range_stepform_id_temp").value;
                
               jQuery( "#"+t+"_elementform_id_temp0" ).removeClass( "ui-spinner-input" )
          .prop( "disabled", false )
          .removeAttr( "autocomplete" )
          .removeAttr( "role" )
          .removeAttr( "aria-valuenow" );
          
          span_ui= document.getElementById(t+"_elementform_id_temp0").parentNode;
            span_ui.parentNode.appendChild(document.getElementById(t+"_elementform_id_temp0"));
            span_ui.parentNode.removeChild(span_ui);
            
            
            jQuery("#"+t+"_elementform_id_temp0")[0].spin = null;
            jQuery("#"+t+"_elementform_id_temp1")[0].spin = null;
            
            spinner0 = jQuery( "#"+t+"_elementform_id_temp0" ).spinner();
            spinner0.spinner( "value", spinner_value0 );
                    jQuery( "#"+t+"_elementform_id_temp0" ).spinner({ step: spinner_step});
            
            
            
            var spinner_value1 = jQuery("#" + t+"_elementform_id_temp1").get( "aria-valuenow" );
                        
               jQuery( "#"+t+"_elementform_id_temp1" ).removeClass( "ui-spinner-input" )
          .prop( "disabled", false )
          .removeAttr( "autocomplete" )
          .removeAttr( "role" )
          .removeAttr( "aria-valuenow" );
          
          span_ui1= document.getElementById(t+"_elementform_id_temp1").parentNode;
            span_ui1.parentNode.appendChild(document.getElementById(t+"_elementform_id_temp1"));
            span_ui1.parentNode.removeChild(span_ui1);
              
            spinner1 = jQuery( "#"+t+"_elementform_id_temp1" ).spinner();
            spinner1.spinner( "value", spinner_value1 );
                    jQuery( "#"+t+"_elementform_id_temp1" ).spinner({ step: spinner_step});
            
              var myu = t;
            jQuery(document).ready(function() {	

        jQuery("#"+myu+"_mini_label_from").click(function() {
        if (jQuery(this).children('input').length == 0) {
          var from = "<input type='text' id='from' class='from' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";
            jQuery(this).html(from);
            jQuery("input.from").focus();
            jQuery("input.from").blur(function() {
          var id_for_blur = document.getElementById('from').parentNode.id.split('_');
          var value = jQuery(this).val();
        jQuery("#"+id_for_blur[0]+"_mini_label_from").text(value);
        });
      }
      });
          
        jQuery("label#"+myu+"_mini_label_to").click(function() {
      if (jQuery(this).children('input').length == 0) {	
      
        var to = "<input type='text' id='to' class='to' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(to);			
          jQuery("input.to").focus();					
          jQuery("input.to").blur(function() {	
          var id_for_blur = document.getElementById('to').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_to").text(value);
        });	
         
      }	
      });
      
      
      
      });	
          }	

        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_name"){
        var myu = t;
            jQuery(document).ready(function() {	

        jQuery("#"+myu+"_mini_label_first").click(function() {		
      
        if (jQuery(this).children('input').length == 0) {	

          var first = "<input type='text' id='first' class='first' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(first);							
            jQuery("input.first").focus();			
            jQuery("input.first").blur(function() {	
          
          var id_for_blur = document.getElementById('first').parentNode.id.split('_');
          var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_first").text(value);		
        });	
      }	
      });	    
          
        jQuery("label#"+myu+"_mini_label_last").click(function() {	
      if (jQuery(this).children('input').length == 0) {	
      
        var last = "<input type='text' id='last' class='last'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(last);			
          jQuery("input.last").focus();					
          jQuery("input.last").blur(function() {	
          var id_for_blur = document.getElementById('last').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_last").text(value);	
        });	
         
      }	
      });
      
        jQuery("label#"+myu+"_mini_label_title").click(function() {		
        if (jQuery(this).children('input').length == 0) {				
          var title = "<input type='text' id='title' class='title' size='10' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(title);							
            jQuery("input.title").focus();			
            jQuery("input.title").blur(function() {	
            var id_for_blur = document.getElementById('title').parentNode.id.split('_');
          var value = jQuery(this).val();			


        jQuery("#"+id_for_blur[0]+"_mini_label_title").text(value);		
        });	
      }	
      
      });		


      jQuery("label#"+myu+"_mini_label_middle").click(function() {	
      if (jQuery(this).children('input').length == 0) {		
        var middle = "<input type='text' id='middle' class='middle'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(middle);			
          jQuery("input.middle").focus();					
          jQuery("input.middle").blur(function() {	
                var id_for_blur = document.getElementById('middle').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_middle").text(value);	
        });	
      }	
      });
      
      });		
         }						
        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_address"){
        var myu = t;
           
      jQuery(document).ready(function() {		
      jQuery("label#"+myu+"_mini_label_street1").click(function() {			

        if (jQuery(this).children('input').length == 0) {				
        var street1 = "<input type='text' id='street1' class='street1' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
        jQuery(this).html(street1);					
        jQuery("input.street1").focus();		
        jQuery("input.street1").blur(function() {	
        var id_for_blur = document.getElementById('street1').parentNode.id.split('_');
        var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_street1").text(value);		
        });		
        }	
        });		
      
      jQuery("label#"+myu+"_mini_label_street2").click(function() {		
      if (jQuery(this).children('input').length == 0) {		
      var street2 = "<input type='text' id='street2' class='street2'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
      jQuery(this).html(street2);					
      jQuery("input.street2").focus();		
      jQuery("input.street2").blur(function() {	
      var id_for_blur = document.getElementById('street2').parentNode.id.split('_');
      var value = jQuery(this).val();			
      jQuery("#"+id_for_blur[0]+"_mini_label_street2").text(value);		
      });		
      }	
      });	
      
      
      jQuery("label#"+myu+"_mini_label_city").click(function() {	
        if (jQuery(this).children('input').length == 0) {	
        var city = "<input type='text' id='city' class='city'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
        jQuery(this).html(city);			
        jQuery("input.city").focus();				
        jQuery("input.city").blur(function() {	
        var id_for_blur = document.getElementById('city').parentNode.id.split('_');		
        var value = jQuery(this).val();		
        jQuery("#"+id_for_blur[0]+"_mini_label_city").text(value);		
      });		
      }	
      });	
      
      jQuery("label#"+myu+"_mini_label_state").click(function() {		
        if (jQuery(this).children('input').length == 0) {	
        var state = "<input type='text' id='state' class='state'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(state);		
          jQuery("input.state").focus();		
          jQuery("input.state").blur(function() {	
        var id_for_blur = document.getElementById('state').parentNode.id.split('_');					
        var value = jQuery(this).val();			
      jQuery("#"+id_for_blur[0]+"_mini_label_state").text(value);	
      });	
      }
      });		

      jQuery("label#"+myu+"_mini_label_postal").click(function() {		
      if (jQuery(this).children('input').length == 0) {			
      var postal = "<input type='text' id='postal' class='postal'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
      jQuery(this).html(postal);			
      jQuery("input.postal").focus();			
      jQuery("input.postal").blur(function() {
        var id_for_blur = document.getElementById('postal').parentNode.id.split('_');	
      var value = jQuery(this).val();		
      jQuery("#"+id_for_blur[0]+"_mini_label_postal").text(value);		
      });	
      }
      });	
      
      
      jQuery("label#"+myu+"_mini_label_country").click(function() {		
        if (jQuery(this).children('input').length == 0) {		
          var country = "<input type='country' id='country' class='country'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";
          jQuery(this).html(country);		
          jQuery("input.country").focus();	
          jQuery("input.country").blur(function() {	
          var id_for_blur = document.getElementById('country').parentNode.id.split('_');				
          var value = jQuery(this).val();			
          jQuery("#"+id_for_blur[0]+"_mini_label_country").text(value);			
          });	
        }	
      });
      });	

         }						
        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_phone"){
        var myu = t;
          
      jQuery(document).ready(function() {	
      jQuery("label#"+myu+"_mini_label_area_code").click(function() {		
      if (jQuery(this).children('input').length == 0) {		

        var area_code = "<input type='text' id='area_code' class='area_code' size='10' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";		

        jQuery(this).html(area_code);		
        jQuery("input.area_code").focus();		
        jQuery("input.area_code").blur(function() {	
        var id_for_blur = document.getElementById('area_code').parentNode.id.split('_');
        var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_area_code").text(value);		
        });		
      }	
      });	

      
      jQuery("label#"+myu+"_mini_label_phone_number").click(function() {		

      if (jQuery(this).children('input').length == 0) {			
        var phone_number = "<input type='text' id='phone_number' class='phone_number'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";						

        jQuery(this).html(phone_number);					

        jQuery("input.phone_number").focus();			
        jQuery("input.phone_number").blur(function() {		
        var id_for_blur = document.getElementById('phone_number').parentNode.id.split('_');
        var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_phone_number").text(value);		
        });	
      }	
      });
      
      });	
         }						
        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_date_fields"){
        var myu = t;
          
      jQuery(document).ready(function() {
      jQuery("label#"+myu+"_day_label").click(function() {		
        if (jQuery(this).children('input').length == 0) {				
          var day = "<input type='text' id='day' class='day' size='8' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(day);							
            jQuery("input.day").focus();			
            jQuery("input.day").blur(function() {	
          var id_for_blur = document.getElementById('day').parentNode.id.split('_');
          var value = jQuery(this).val();			

        jQuery("#"+id_for_blur[0]+"_day_label").text(value);		
        });	
      }	
      });		


      jQuery("label#"+myu+"_month_label").click(function() {	
      if (jQuery(this).children('input').length == 0) {		
        var month = "<input type='text' id='month' class='month' size='8' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(month);			
          jQuery("input.month").focus();					
          jQuery("input.month").blur(function() {	
          var id_for_blur = document.getElementById('month').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_month_label").text(value);	
        });	
      }	
      });
      
        jQuery("label#"+myu+"_year_label").click(function() {	
      if (jQuery(this).children('input').length == 0) {		
        var year = "<input type='text' id='year' class='year' size='8' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(year);			
          jQuery("input.year").focus();					
          jQuery("input.year").blur(function() {	
        var id_for_blur = document.getElementById('year').parentNode.id.split('_');				
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_year_label").text(value);	
        });	
      }	
      });
      
      });	

      
         }						
          else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_time"){
        var myu = t;
          
    jQuery(document).ready(function() {	
      jQuery("label#"+myu+"_mini_label_hh").click(function() {		
        if (jQuery(this).children('input').length == 0) {				
          var hh = "<input type='text' id='hh' class='hh' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(hh);							
            jQuery("input.hh").focus();			
            jQuery("input.hh").blur(function() {	
            var id_for_blur = document.getElementById('hh').parentNode.id.split('_');	
          var value = jQuery(this).val();			


        jQuery("#"+id_for_blur[0]+"_mini_label_hh").text(value);		
        });	
      }	
      });		


      jQuery("label#"+myu+"_mini_label_mm").click(function() {	
      if (jQuery(this).children('input').length == 0) {		
        var mm = "<input type='text' id='mm' class='mm' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(mm);			
          jQuery("input.mm").focus();					
          jQuery("input.mm").blur(function() {
                var id_for_blur = document.getElementById('mm').parentNode.id.split('_');				
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_mm").text(value);	
        });	
      }	
      });
      
        jQuery("label#"+myu+"_mini_label_ss").click(function() {	
      if (jQuery(this).children('input').length == 0) {		
        var ss = "<input type='text' id='ss' class='ss' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(ss);			
          jQuery("input.ss").focus();					
          jQuery("input.ss").blur(function() {
       var id_for_blur = document.getElementById('ss').parentNode.id.split('_');				
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_ss").text(value);	
        });	
      }	
      });
      
        jQuery("label#"+myu+"_mini_label_am_pm").click(function() {		
        if (jQuery(this).children('input').length == 0) {				
          var am_pm = "<input type='text' id='am_pm' class='am_pm' size='4' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(am_pm);							
            jQuery("input.am_pm").focus();			
            jQuery("input.am_pm").blur(function() {	
            var id_for_blur = document.getElementById('am_pm').parentNode.id.split('_');	
          var value = jQuery(this).val();			

        jQuery("#"+id_for_blur[0]+"_mini_label_am_pm").text(value);		
        });	
      }	
      });	
      });
        
         }	

        else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_paypal_price"){
        var myu = t;
            jQuery(document).ready(function() {	

        jQuery("#"+myu+"_mini_label_dollars").click(function() {		
      
        if (jQuery(this).children('input').length == 0) {	

          var dollars = "<input type='text' id='dollars' class='dollars' style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(dollars);							
            jQuery("input.dollars").focus();			
            jQuery("input.dollars").blur(function() {	
          
          var id_for_blur = document.getElementById('dollars').parentNode.id.split('_');
          var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_dollars").text(value);		
        });	
      }	
      });	    
          
        jQuery("label#"+myu+"_mini_label_cents").click(function() {	
      if (jQuery(this).children('input').length == 0) {	
      
        var cents = "<input type='text' id='cents' class='cents'  style='outline:none; border:none; background:none;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(cents);			
          jQuery("input.cents").focus();					
          jQuery("input.cents").blur(function() {	
          var id_for_blur = document.getElementById('cents').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_cents").text(value);	
        });	
         
      }	
      });
      });
      }
      else
           if(document.getElementById(t+"_typeform_id_temp").value=="type_scale_rating"){
        var myu = t;
            jQuery(document).ready(function() {	

        jQuery("#"+myu+"_mini_label_worst").click(function() {		
      
        if (jQuery(this).children('input').length == 0) {	

          var worst = "<input type='text' id='worst' class='worst' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";	
            jQuery(this).html(worst);							
            jQuery("input.worst").focus();			
            jQuery("input.worst").blur(function() {	
          
          var id_for_blur = document.getElementById('worst').parentNode.id.split('_');
          var value = jQuery(this).val();			
        jQuery("#"+id_for_blur[0]+"_mini_label_worst").text(value);		
        });	
      }	
      });	    
          
        jQuery("label#"+myu+"_mini_label_best").click(function() {	
      if (jQuery(this).children('input').length == 0) {	
      
        var best = "<input type='text' id='best' class='best' size='6' style='outline:none; border:none; background:none; font-size:11px;' value=\""+jQuery(this).text()+"\">";	
          jQuery(this).html(best);			
          jQuery("input.best").focus();					
          jQuery("input.best").blur(function() {	
          var id_for_blur = document.getElementById('best').parentNode.id.split('_');			
          var value = jQuery(this).val();			
          
          jQuery("#"+id_for_blur[0]+"_mini_label_best").text(value);	
        });	
         
      }	
      });
      
      
      
      });		
       }
          }
          form_view = 1;
          form_view_count = 0;
          for (i = 1; i <= 30; i++) {
            if (document.getElementById('form_id_tempform_view'+i)) {
              form_view_count++;
              form_view_max=i;
            }
          }
          if (form_view_count > 1) {
            for (i=1; i<=form_view_max; i++) {
              if (document.getElementById('form_id_tempform_view'+i)) {
                first_form_view=i;
                break;
              }
            }
            form_view=form_view_max;
            generate_page_nav(first_form_view);
            var img_EDIT = document.createElement("img");
            img_EDIT.setAttribute("src", "<?php echo WD_FMC_URL . '/images/edit.png'; ?>");
            img_EDIT.style.cssText = "margin-left:40px; cursor:pointer";
            img_EDIT.setAttribute("onclick", 'el_page_navigation()');
            var td_EDIT = document.getElementById("edit_page_navigation");
            td_EDIT.appendChild(img_EDIT);
            document.getElementById('page_navigation').appendChild(td_EDIT);
          }
          //if(document.getElementById('take').innerHTML.indexOf('up_row(')==-1) location.reload(true);
          //else 
          
          document.getElementById('form').value=document.getElementById('take').innerHTML;
          document.getElementById('araqel').value = 1;
        }
        jQuery(window).load(function () {
          formOnload();
        });
      </script>

      <input type="hidden" name="option" value="com_formmaker" />
      <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
      <input type="hidden" name="cid[]" value="<?php echo $row->id; ?>" />

      <input type="hidden" id="task" name="task" value=""/>
      <input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
    </form>
    <script>
      jQuery(window).load(function() {
        fm_popup();
      });
    </script>
    <?php
  }

  public function form_options_old($id) {
    $row = $this->model->get_row_data($id);
    $themes = $this->model->get_theme_rows_data('_old');
    $page_title = $row->title . ' form options';
    $label_id = array();
    $label_label = array();
    $label_type = array();
    $label_all = explode('#****#', $row->label_order_current);
    $label_all = array_slice($label_all, 0, count($label_all) - 1);
    foreach ($label_all as $key => $label_each) {
      $label_id_each = explode('#**id**#', $label_each);
      array_push($label_id, $label_id_each[0]);
      $label_order_each = explode('#**label**#', $label_id_each[1]);
      array_push($label_label, $label_order_each[0]);
      array_push($label_type, $label_order_each[1]);
    }
    ?>
    <script>
      gen = "<?php echo $row->counter; ?>";
      form_view_max = 20;
      function set_preview() {
        document.getElementById('preview_form').href = '<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php')); ?>&id='+document.getElementById('theme').value+'&width=1000&height=500&TB_iframe=1';
      }
    </script>
    <div style="font-size: 14px; font-weight: bold;">
        This section allows you to edit form options.
        <a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-3.html">Read More in User Manual</a>
      </div>
    <form class="wrap" method="post" action="admin.php?page=manage_fmc" style="width:99%;" name="adminForm" id="adminForm">
      <?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
      <h2><?php echo $page_title; ?></h2>
      <div style="float: right; margin: 0 5px 0 0;">
        <input class="button-secondary" type="submit" onclick="if (fm_check_email('mail') ||
                                                                   fm_check_email('from_mail') ||
                                                                   fm_check_email('paypal_email')) {return false;}; fm_set_input_value('task', 'save_options_old')" value="Save"/>
        <input class="button-secondary" type="submit" onclick="if (fm_check_email('mail') ||
                                                                   fm_check_email('from_mail') ||
                                                                   fm_check_email('paypal_email')) {return false;}; fm_set_input_value('task', 'apply_options_old')" value="Apply"/>
        <input class="button-secondary" type="submit" onclick="fm_set_input_value('task', 'cancel_options_old')" value="Cancel"/>
      </div>
      <input type="hidden" name="take" id="take" value="<?php $row->form ?>">
      <div class="submenu-box" style="width: 99%; float: left; margin: 15px 0 0 0;">
        <div class="submenu-pad">
          <ul id="submenu" class="configuration">
            <li>
              <a id="general" class="fm_fieldset_tab" onclick="form_maker_options_tabs('general')" href="#">General Options</a>
            </li>
            <li>
              <a id="actions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('actions')" href="#">Actions after Submission</a>
            </li>
            <li>
              <a id="payment" class="fm_fieldset_tab" onclick="form_maker_options_tabs('payment')" href="#">Payment Options</a>
            </li>
            <li>
              <a id="javascript" class="fm_fieldset_tab" onclick="form_maker_options_tabs('javascript')" href="#">JavaScript</a>
            </li>
            <li>
              <a id="custom" class="fm_fieldset_tab" onclick="form_maker_options_tabs('custom')" href="#">Custom Text in Email</a>
            </li>
          </ul>
        </div>
      </div>
      <fieldset id="actions_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">Actions after submission</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label>Action type</label>
            </td>
            <td class="fm_options_value">
              <div><input type="radio" name="submit_text_type" id="text_type_none" onclick="set_type('none')" value="1" <?php echo ($row->submit_text_type != 2 && $row->submit_text_type != 3 && $row->submit_text_type != 4 && $row->submit_text_type != 5) ? "checked" : ""; ?> /><label for="text_type_none">Stay on Form</label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_post" onclick="set_type('post')" value="2" <?php echo ($row->submit_text_type == 2) ? "checked" : ""; ?> /><label for="text_type_post">Post</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_page" onclick="set_type('page')" value="5" <?php echo ($row->submit_text_type == 5) ? "checked" : ""; ?> /><label for="text_type_page">Page</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_custom_text" onclick="set_type('custom_text')" value="3" <?php echo ($row->submit_text_type == 3 ) ? "checked" : ""; ?> /><label for="text_type_custom_text">Custom Text</label></label></div>
              <div><input type="radio" name="submit_text_type" id="text_type_url" onclick="set_type('url')" value="4" <?php echo ($row->submit_text_type == 4) ? "checked" : ""; ?> /><label for="text_type_url">URL</div>
            </td>
          </tr>
			<tr id="none" <?php echo (($row->submit_text_type == 2 || $row->submit_text_type == 3 || $row->submit_text_type == 4 || $row->submit_text_type == 5) ? 'style="display:none"' : ''); ?>>
				<td class="fm_options_label">
				  <label>Stay on Form</label>
				</td>
				<td class="fm_options_value">
				  <img src="<?php echo WD_FMC_URL . '/images/tick.png'; ?>" border="0">
				</td>
			</tr>
			<tr id="post" <?php echo (($row->submit_text_type != 2) ? 'style="display:none"' : ''); ?>>
				<td class="fm_options_label">
					<label for="post_name">Post</label>
				</td>
				<td class="fm_options_value">
					<select id="post_name" name="post_name">
						<option value="0">- Select Post -</option>
						<?php
						// The Query.
						$args = array('posts_per_page'  => 10000);
						query_posts($args);
						// The Loop.
						while (have_posts()) : the_post(); ?>
						<option value="<?php $x = get_permalink(get_the_ID()); echo $x; ?>" <?php echo (($row->article_id == $x) ? 'selected="selected"' : ''); ?>><?php the_title(); ?></option>
						<?php
						endwhile;
						// Reset Query.
						wp_reset_query();
						?>
					</select>
				</td>
			</tr>
			<tr id="page" <?php echo (($row->submit_text_type != 5) ? 'style="display:none"' : ''); ?>>
				<td class="fm_options_label">
					<label for="page_name">Page</label>
				</td>
				<td class="fm_options_value">
					<select id="page_name" name="page_name" style="width:153px; font-size:11px;">
						<option value="0">- Select Page -</option>
						<?php
						// The Query.
						$pages = get_pages();
						// The Loop.
						foreach ($pages as $page) {
						  $page_id = get_page_link($page->ID);
						  ?>
						<option value="<?php echo $page_id; ?>" <?php echo (($row->article_id == $page_id) ? 'selected="selected"' : ''); ?>><?php echo $page->post_title; ?></option>
						  <?php
						}
						// Reset Query.
						wp_reset_query();
						?>
					</select>
				</td>
			</tr>
			<tr id="custom_text" <?php echo (($row->submit_text_type != 3) ? 'style="display: none;"' : ''); ?>>
				<td class="fm_options_label">
					<label for="submit_text">Text</label>
				</td>
				<td class="fm_options_value">
					<?php
					if (user_can_richedit()) {
						wp_editor($row->submit_text, 'submit_text', array('teeny' => FALSE, 'textarea_name' => 'submit_text', 'media_buttons' => FALSE, 'textarea_rows' => 5));
					}
					else {
						?>
						<textarea cols="36" rows="5" id="submit_text" name="submit_text" style="resize: vertical;">
							<?php echo $row->submit_text; ?>
						</textarea>
						<?php
					}
					?>
				</td>
			</tr>
			<tr id="url" <?php echo (($row->submit_text_type != 4 ) ? 'style="display:none"' : ''); ?>>
				<td class="fm_options_label">
					<label for="url">URL</label>
				</td>
				<td class="fm_options_value">
					<input type="text" id="url" name="url" style="width:300px" value="<?php echo $row->url; ?>" />
				</td>
			</tr>
        </table>
		</fieldset>
      <fieldset id="custom_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">Custom text in email</legend>
        <table class="admintable">
          <tr>
            <td class="fm_options_label" valign="top">
              <label>For Administrator</label>
            </td>
            <td class="fm_options_value">
              <div style="margin-bottom:5px">
                <?php
                $choise = "document.getElementById('script_mail')";
                for ($i = 0; $i < count($label_label); $i++) {
                  if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button") {
                    continue;
                  }
                  $param = htmlspecialchars(addslashes($label_label[$i]));
                  ?>
                  <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php echo htmlspecialchars(addslashes($label_label[$i])); ?>" onClick="insertAtCursor(<?php echo $choise; ?>, '<?php echo $param; ?>')" />
                  <?php
                }
                ?>
                <input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php echo $choise; ?>, 'all')" />
              </div>
              <?php
              if (user_can_richedit()) {
                wp_editor($row->script_mail, 'script_mail', array('teeny' => FALSE, 'textarea_name' => 'script_mail', 'media_buttons' => FALSE, 'textarea_rows' => 5));
              }
              else {
                ?>
                <textarea name="script_mail" id="script_mail" cols="20" rows="10" style="width:300px; height:450px;"><?php echo $row->script_mail; ?></textarea>
                <?php
              }
              ?>
            </td>
          </tr>
          <tr>
            <td valign="top" height="30"></td>
            <td valign="top"></td>
          </tr>
          <tr>
            <td class="fm_options_label" valign="top">
              <label>For User</label>
            </td>
            <td class="fm_options_value">
              <div style="margin-bottom:5px">
                <?php
                $choise = "document.getElementById('script_mail_user')";
                for ($i = 0; $i < count($label_label); $i++) {
                  if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button") {
                    continue;
                  }
                  $param = htmlspecialchars(addslashes($label_label[$i]));
                  ?>
                  <input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php echo htmlspecialchars(addslashes($label_label[$i])); ?>" onClick="insertAtCursor(<?php echo $choise; ?>, '<?php echo $param; ?>')" />
                  <?php
                }
                ?>
                <input style="border: 1px solid silver; font-size: 10px; margin:3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php echo $choise; ?>, 'all')" />
              </div>
              <?php
              if (user_can_richedit()) {
                wp_editor($row->script_mail_user, 'script_mail_user', array('teeny' => FALSE, 'textarea_name' => 'script_mail_user', 'media_buttons' => FALSE, 'textarea_rows' => 5));
              }
              else {
                ?>
                <textarea name="script_mail_user" id="script_mail_user" cols="20" rows="10" style="width:300px; height:450px;"><?php echo $row->script_mail_user; ?></textarea>
                <?php
              }
              ?>
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="general_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">General Options</legend>
        <table class="admintable" style="float:left">
          <tr valign="top">
            <td class="fm_options_label">
              <label for="mail">Email to send submissions to</label>
            </td>
            <td class="fm_options_value">
              <input id="mail" name="mail" value="<?php echo $row->mail; ?>" style="width:250px;" />
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="from_mail">From Email</label>
            </td>
            <td class="fm_options_value">
              <input id="from_mail" name="from_mail" value="<?php echo $row->from_mail; ?>" style="width:250px;" />
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="from_name">From Name</label>
            </td>
            <td class="fm_options_value">
              <input id="from_name" name="from_name" value="<?php echo $row->from_name; ?>" style="width:250px;"/>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="theme">Theme</label>
            </td>
            <td class="fm_options_value">
              <select id="theme" name="theme" style="width:260px;" onChange="set_preview()">
                <?php
                foreach ($themes as $theme) {
                  ?>
                  <option value="<?php echo $theme->id; ?>" <?php echo (($theme->id == $row->theme) ? 'selected' : ''); ?>><?php echo $theme->title; ?></option>
                  <?php
                }
                ?>
              </select>
              <a href="<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'id' => $row->theme, 'form_id' => $row->id, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>" class="button-primary thickbox thickbox-preview" id="preview_form" title="Form Preview" onclick="return false;">
                Preview
              </a>
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="payment_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">Payment Options</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label>Turn Paypal On</label>
            </td>
            <td class="fm_options_value">
              <div><input type="radio" name="paypal_mode" id="paypal_mode1" value="1" <?php echo ($row->paypal_mode == "1") ? "checked" : ""; ?> /><label for="paypal_mode1">On</label></div>
              <div><input type="radio" name="paypal_mode" id="paypal_mode2" value="0" <?php echo ($row->paypal_mode != "1") ? "checked" : ""; ?> /><label for="paypal_mode2">Off</label></div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label>Checkout Mode</label>
            </td>
            <td class="fm_options_value">
              <div><input type="radio" name="checkout_mode" id="checkout_mode1" value="production" <?php echo ($row->checkout_mode == "production") ? "checked" : ""; ?> /><label for="checkout_mode1">Production</label></div>
              <div><input type="radio" name="checkout_mode" id="checkout_mode2" value="testmode" <?php echo ($row->checkout_mode != "production") ? "checked" : ""; ?> /><label for="checkout_mode2">Testmode</label></div>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="paypal_email">Paypal email</label>
            </td>
            <td class="fm_options_value">
              <input type="text" name="paypal_email" id="paypal_email" value="<?php echo $row->paypal_email; ?>" class="text_area" style="width:250px">
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="payment_currency">Payment Currency</label>
            </td>
            <td class="fm_options_value">
              <select id="payment_currency" name="payment_currency" style="width:253px">
                <option value="USD" <?php echo (($row->payment_currency == 'USD') ? 'selected' : ''); ?>>$ &#8226; U.S. Dollar</option>
                <option value="EUR" <?php echo (($row->payment_currency == 'EUR') ? 'selected' : ''); ?>>&#8364; &#8226; Euro</option>
                <option value="GBP" <?php echo (($row->payment_currency == 'GBP') ? 'selected' : ''); ?>>&#163; &#8226; Pound Sterling</option>
                <option value="JPY" <?php echo (($row->payment_currency == 'JPY') ? 'selected' : ''); ?>>&#165; &#8226; Japanese Yen</option>
                <option value="CAD" <?php echo (($row->payment_currency == 'CAD') ? 'selected' : ''); ?>>C$ &#8226; Canadian Dollar</option>
                <option value="MXN" <?php echo (($row->payment_currency == 'MXN') ? 'selected' : ''); ?>>Mex$ &#8226; Mexican Peso</option>
                <option value="HKD" <?php echo (($row->payment_currency == 'HKD') ? 'selected' : ''); ?>>HK$ &#8226; Hong Kong Dollar</option>
                <option value="HUF" <?php echo (($row->payment_currency == 'HUF') ? 'selected' : ''); ?>>Ft &#8226; Hungarian Forint</option>
                <option value="NOK" <?php echo (($row->payment_currency == 'NOK') ? 'selected' : ''); ?>>kr &#8226; Norwegian Kroner</option>
                <option value="NZD" <?php echo (($row->payment_currency == 'NZD') ? 'selected' : ''); ?>>NZ$ &#8226; New Zealand Dollar</option>
                <option value="SGD" <?php echo (($row->payment_currency == 'SGD') ? 'selected' : ''); ?>>S$ &#8226; Singapore Dollar</option>
                <option value="SEK" <?php echo (($row->payment_currency == 'SEK') ? 'selected' : ''); ?>>kr &#8226; Swedish Kronor</option>
                <option value="PLN" <?php echo (($row->payment_currency == 'PLN') ? 'selected' : ''); ?>>zl &#8226; Polish Zloty</option>
                <option value="AUD" <?php echo (($row->payment_currency == 'AUD') ? 'selected' : ''); ?>>A$ &#8226; Australian Dollar</option>
                <option value="DKK" <?php echo (($row->payment_currency == 'DKK') ? 'selected' : ''); ?>>kr &#8226; Danish Kroner</option>
                <option value="CHF" <?php echo (($row->payment_currency == 'CHF') ? 'selected' : ''); ?>>CHF &#8226; Swiss Francs</option>
                <option value="CZK" <?php echo (($row->payment_currency == 'CZK') ? 'selected' : ''); ?>>Kc &#8226; Czech Koruny</option>
                <option value="ILS" <?php echo (($row->payment_currency == 'ILS') ? 'selected' : ''); ?>>&#8362; &#8226; Israeli Sheqel</option>
                <option value="BRL" <?php echo (($row->payment_currency == 'BRL') ? 'selected' : ''); ?>>R$ &#8226; Brazilian Real</option>
                <option value="TWD" <?php echo (($row->payment_currency == 'TWD') ? 'selected' : ''); ?>>NT$ &#8226; Taiwan New Dollars</option>
                <option value="MYR" <?php echo (($row->payment_currency == 'MYR') ? 'selected' : ''); ?>>RM &#8226; Malaysian Ringgit</option>
                <option value="PHP" <?php echo (($row->payment_currency == 'PHP') ? 'selected' : ''); ?>>&#8369; &#8226; Philippine Peso</option>
                <option value="THB" <?php echo (($row->payment_currency == 'THB') ? 'selected' : ''); ?>>&#xe3f; &#8226; Thai Bahtv</option>
              </select>
            </td>
          </tr>
          <tr valign="top">
            <td class="fm_options_label">
              <label for="tax">Tax</label>
            </td>
            <td class="fm_options_value">
              <input type="text" name="tax" id="tax" value="<?php echo $row->tax; ?>" class="text_area" style="width: 40px;" onKeyPress="return check_isnum_point(event)"> %
            </td>
          </tr>
        </table>
      </fieldset>
      <fieldset id="javascript_fieldset" class="adminform fm_fieldset_deactive">
        <legend style="color:#0B55C4;font-weight: bold;">JavaScript</legend>
        <table class="admintable">
          <tr valign="top">
            <td class="fm_options_label">
              <label for="javascript">Javascript</label>
            </td>
            <td class="fm_options_value">
              <textarea style="margin: 0px;" cols="60" rows="30" name="javascript" id="javascript"><?php echo $row->javascript; ?></textarea>
            </td>
          </tr>
        </table>
      </fieldset>
      <input type="hidden" name="fieldset_id" id="fieldset_id" value="<?php echo WDW_FMC_Library::get('fieldset_id', 'general'); ?>" />
      <input type="hidden" id="task" name="task" value=""/>
      <input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
    </form>
    <script>
      jQuery(window).load(function () {
        form_maker_options_tabs(jQuery("#fieldset_id").val());
        fm_popup();
      });
    </script>
    <?php
  }
    
	public function form_options($id) {
		
	
		$row = $this->model->get_row_data($id);
		$themes = $this->model->get_theme_rows_data();
		$queries = $this->model->get_queries_rows_data($id);
		$userGroups = get_editable_roles();
		$page_title = $row->title . ' form options';
		$label_id = array();
		$label_label = array();
		$label_type = array();
		$label_all = explode('#****#', $row->label_order_current);
		$label_all = array_slice($label_all, 0, count($label_all) - 1);
		foreach ($label_all as $key => $label_each) {
			$label_id_each = explode('#**id**#', $label_each);
			array_push($label_id, $label_id_each[0]);
			$label_order_each = explode('#**label**#', $label_id_each[1]);
			array_push($label_label, $label_order_each[0]);
			array_push($label_type, $label_order_each[1]);
		}
		$fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
		$fields_count = count($fields);
		?>
		<script>
			function fm_change_radio_checkbox_text(elem) {
				var labels_array = [];
					labels_array['paypal_mode'] = ['Off', 'On'];
					labels_array['checkout_mode'] = ['Testmode', 'Production'];
					labels_array['mail_mode'] = ['Text', 'HTML'];
					labels_array['mail_mode_user'] = ['Text', 'HTML'];
					labels_array['value'] = ['1', '0'];
				
				jQuery(elem).val(labels_array['value'][jQuery(elem).val()]);
				jQuery(elem).next().val(jQuery(elem).val());
				
				var clicked_element = labels_array[jQuery(elem).attr('name')];
				jQuery(elem).find('label').html(clicked_element[jQuery(elem).val()]);
				if(jQuery( elem ).hasClass( "fm-text-yes" )) {
					jQuery( elem ).removeClass('fm-text-yes').addClass('fm-text-no');
					jQuery(elem).find("span").animate({
						right: parseInt(jQuery( elem ).css( "width")) - 14 + 'px'
					}, 400, function() {
					}); 
				}	
				else {
					jQuery( elem ).removeClass('fm-text-no').addClass('fm-text-yes');
					jQuery(elem).find("span").animate({
						right: 0
					}, 400, function() {
					}); 
				}		
			}
			
			gen = "<?php echo $row->counter; ?>";
			form_view_max = 20;
			function set_preview() {
				jQuery("#preview_form").attr("onclick", "tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php')); ?>&test_theme=" + jQuery('#theme').val() + "&width=1000&height=500&TB_iframe=1'); return false;");
				jQuery("#edit_css").attr("onclick", "tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'form_id' => $row->id), admin_url('admin-ajax.php')); ?>&id=" + jQuery('#theme').val() + "&width=800&height=500&TB_iframe=1'); return false;");
			}
			
			function set_condition() {
				field_condition = '';
				for(i=0;i<500;i++) {
					conditions = '';
					if(document.getElementById("condition"+i)) {
						field_condition+=document.getElementById("show_hide"+i).value+"*:*show_hide*:*";
						field_condition+=document.getElementById("fields"+i).value+"*:*field_label*:*";
						field_condition+=document.getElementById("all_any"+i).value+"*:*all_any*:*";
						for(k=0;k<500;k++) {
							if(document.getElementById("condition_div"+i+"_"+k)) {
								conditions+=document.getElementById("field_labels"+i+"_"+k).value+"***";
								conditions+=document.getElementById("is_select"+i+"_"+k).value+"***";
								if(document.getElementById("field_value"+i+"_"+k).tagName=="SELECT" ) {
									if(document.getElementById("field_value"+i+"_"+k).getAttribute('multiple')) {
										var sel = document.getElementById("field_value"+i+"_"+k);
										var selValues = '';
										for(m=0; m < sel.length; m++) {
											if(sel.options[m].selected)
											
											selValues += sel.options[m].value+"@@@";
										}
										conditions+=selValues;
									} else {
										conditions+=document.getElementById("field_value"+i+"_"+k).value;
									}								
								}
								else
									conditions+=document.getElementById("field_value"+i+"_"+k).value;
								conditions+="*:*next_condition*:*";
							}
						}
						field_condition+=conditions;
						field_condition+="*:*new_condition*:*";
					}
				}
				document.getElementById('condition').value = field_condition;
			}      
    
			function show_verify_options(s){
				if(s){
					jQuery(".verification_div").removeAttr( "style" );
					jQuery(".expire_link").removeAttr( "style" );
						
				} else{
					jQuery(".verification_div").css( 'display', 'none' );
					jQuery(".expire_link").css( 'display', 'none' );
				}
			}
		</script>
		<style>
		.CodeMirror {
			border: 1px solid #ccc;
			font-size: 12px;
			margin-bottom: 6px;
			background: white;
		}
		</style>
		<div class="fm-user-manual">
			This section allows you to edit form options.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-3.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form class="wrap" method="post" action="admin.php?page=manage_fmc" style="width:99%;" name="adminForm" id="adminForm">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<div class="fm-page-header">
				<div class="fm-page-title" style="width: inherit;">
					<?php echo $page_title; ?>
				</div>
				<div class="fm-page-actions">
					<button class="fm-button save-button small" onclick="if (fm_check_email('mailToAdd') ||fm_check_email('from_mail') || fm_check_email('reply_to') || fm_check_email('mail_from_user') || fm_check_email('reply_to_user') || fm_check_email('mail_from_other') || fm_check_email('reply_to_other') || fm_check_email('paypal_email')) {return false;}; set_condition(); wd_fm_apply_options('save_options');">
						<span></span>
						Save
					</button>
					<button class="fm-button apply-button small" onclick="if (fm_check_email('mailToAdd') ||  fm_check_email('from_mail') || fm_check_email('reply_to') || fm_check_email('mail_from_user') || fm_check_email('reply_to_user') || fm_check_email('mail_from_other') || fm_check_email('reply_to_other') || fm_check_email('paypal_email')) {return false;}; set_condition(); wd_fm_apply_options('apply_options');">
						<span></span>
						Apply
					</button>
					<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', 'cancel_options');">
						<span></span>
						Cancel
					</button>
				</div>
				<div class="fm-clear"></div>
			</div>	
			<div class="fm-form-options">
				<div class="submenu-box">
					<div class="submenu-pad">
						<ul id="submenu" class="configuration">
							<li>
								<a id="general" class="fm_fieldset_tab" onclick="form_maker_options_tabs('general')" href="#">General Options</a>
							</li>
							<li>
								<a id="custom" class="fm_fieldset_tab" onclick="form_maker_options_tabs('custom')" href="#">Email Options</a>
							</li>
							<li>
								<a id="actions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('actions')" href="#">Actions after Submission</a>
							</li>
							<li>
								<a id="payment" class="fm_fieldset_tab" onclick="form_maker_options_tabs('payment')" href="#">Payment Options</a>
							</li>
							<li>
								<a id="javascript" class="fm_fieldset_tab" onclick="form_maker_options_tabs('javascript'); codemirror_for_javascript();" href="#">JavaScript</a>
							</li>
							<li>
								<a id="conditions" class="fm_fieldset_tab" onclick="form_maker_options_tabs('conditions')" href="#">Conditional Fields</a>
							</li>
							
						</ul>
					</div>
				</div>
				<fieldset id="general_fieldset" class="adminform fm_fieldset_deactive">
					<legend>General Options</legend>
						<table class="admintable" >
							<tr valign="top">
								<td class="fm_options_label">
									<label>Published</label>
								</td>
								<td class="fm_options_value">
									<button class="fm-checkbox-radio-button <?php echo $row->published == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->published; ?>">
										<span></span>
									</button>
									<input type="hidden" name="published" value="<?php echo $row->published; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label>Save data(to database)</label>
								</td>
								<td class="fm_options_value">
									<button class="fm-checkbox-radio-button <?php echo $row->savedb == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->savedb; ?>">
										<span></span>
									</button>
									<input type="hidden" name="savedb" value="<?php echo $row->savedb; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="theme">Theme</label>
								</td>
								<td class="fm_options_value">
									<select id="theme" name="theme" onChange="set_preview()">
										<?php
										foreach ($themes as $theme) {
											?>
											<option value="<?php echo $theme->id; ?>" <?php echo (($theme->id == $row->theme) ? 'selected' : ''); ?>><?php echo $theme->title; ?></option>
											<?php
										}
										?>
									</select>
									<button id="preview_form" class="fm-button preview-button small" onclick="tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerPreview_fmc', 'form_id' => $row->id, 'test_theme' => $row->theme, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>'); return false;">
										<span></span>
										Preview
									</button>
									<button id="edit_css" class="fm-button options-edit-button small" onclick="tb_show('', '<?php echo add_query_arg(array('action' => 'FormMakerEditCSS_fmc', 'id' => $row->theme, 'form_id' => $row->id, 'width' => '1000', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>'); return false;">
										<span></span>
										Edit CSS
									</button>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="requiredmark">Required fields mark</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="requiredmark" name="requiredmark" value="<?php echo $row->requiredmark; ?>" style="width:250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label>Save Uploads</label>
								</td>
								<td class="fm_options_value">
									<button class="fm-checkbox-radio-button <?php echo $row->save_uploads == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->save_uploads; ?>">
										<span></span>
									</button>
									<input type="hidden" name="save_uploads" value="<?php echo $row->save_uploads; ?>"/>
								</td>
							</tr>
						</table>
						<br/>
						<div class="error_fm" style="padding: 5px; font-size: 14px;">Front end submissions are disabled in free version.</div>
						<fieldset class="adminform">
							<legend>Front end submissions access level</legend>
							<table>
								<tr>
									<td class="key">
										<label for="name">Allow User to see submissions:</label>
									</td>
									<td>
										<?php
										$checked_UserGroup=explode(',',$row->user_id_wd);
										$i = 0;
										foreach($userGroups as $val => $uG) {
											echo '<input type="checkbox" value="'.$val .'"  id="user_'.$i.'"';                  
											if(in_array($val ,$checked_UserGroup))
												echo 'checked="checked"';                  
											echo 'onchange="acces_level('.count($userGroups).')" disabled/><label for="user_'.$i.'">'.$uG["name"].'</label><br>';
											$i++;
										}
										?>
										<input type="checkbox" value="guest"  id="user_<?php echo $i; ?>" onchange="acces_level(<?php echo count($userGroups); ?>)"<?php echo (in_array('guest', $checked_UserGroup) ? 'checked="checked"' : '') ?> disabled/><label for="user_<?php echo $i; ?>">Guest</label>
										<input type="hidden" name="user_id_wd" value="<?php echo $row->user_id_wd ?>" id="user_id_wd" />
									</td>
								</tr>              
							</table>
						</fieldset>
						<?php
						$labels_for_submissions = $this->model->get_labels($id);
						$payment_info = $this->model->is_paypal($id);
						$labels_id_for_submissions= array();
						$label_titles_for_submissions=array();
						$labels_type_for_submissions= array();
						if($labels_for_submissions) {
							$label_id_for_submissions= array();
							$label_order_original_for_submissions= array();
							$label_type_for_submissions= array();
							
							if(strpos($row->label_order, 'type_paypal_')) {
								$row->label_order=$row->label_order."item_total#**id**#Item Total#**label**#type_paypal_payment_total#****#total#**id**#Total#**label**#type_paypal_payment_total#****#0#**id**#Payment Status#**label**#type_paypal_payment_status#****#";
							}
							
							$label_all_for_submissions	= explode('#****#',$row->label_order);
							$label_all_for_submissions 	= array_slice($label_all_for_submissions,0, count($label_all_for_submissions)-1);   
							foreach($label_all_for_submissions as $key => $label_each) {
								$label_id_each=explode('#**id**#',$label_each);
								array_push($label_id_for_submissions, $label_id_each[0]);
								$label_order_each=explode('#**label**#', $label_id_each[1]);
								array_push($label_order_original_for_submissions, $label_order_each[0]);
								array_push($label_type_for_submissions, $label_order_each[1]);
							}
							
							foreach($label_id_for_submissions as $key => $label) {
								if(in_array($label, $labels_for_submissions)) {
									array_push($labels_type_for_submissions, $label_type_for_submissions[$key]);
									array_push($labels_id_for_submissions, $label);
									array_push($label_titles_for_submissions, $label_order_original_for_submissions[$key]);
								}
							}
						}
						
						$stats_labels = array();
						$stats_labels_ids = array();
						foreach($labels_type_for_submissions as $key => $label_type_cur) {
							if($label_type_cur=="type_checkbox" || $label_type_cur=="type_radio" || $label_type_cur=="type_own_select" || $label_type_cur=="type_country" || $label_type_cur=="type_paypal_select" || $label_type_cur=="type_paypal_radio" || $label_type_cur=="type_paypal_checkbox" || $label_type_cur=="type_paypal_shipping") {
								$stats_labels_ids[] = $labels_id_for_submissions[$key];
								$stats_labels[] = $label_titles_for_submissions[$key];
							}
						}
						?>
						<script type="text/javascript">
							function inArray(needle, myarray) {
								var length = myarray.length;
								for(var i = 0; i < length; i++) {
									if(myarray[i] == needle) return true;
								}
								return false;
							}

							function checked_labels(class_name) {
								var checked_ids ='';            
								jQuery('.'+class_name).each(function() {
								  if(this.checked) {
									checked_ids += this.value+',';		
								  }
								}); 
								
								if(class_name == 'filed_label') {
									document.getElementById("frontend_submit_fields").value = checked_ids ;
									if(checked_ids == document.getElementById("all_fields").value)
										document.getElementById("all_fields").checked = true;
									else
										document.getElementById("all_fields").checked = false;
								}
								else {
								  document.getElementById("frontend_submit_stat_fields").value = checked_ids ;
								  if(checked_ids == document.getElementById("all_stats_fields").value)
									document.getElementById("all_stats_fields").checked = true;
								  else
									document.getElementById("all_stats_fields").checked = false;
								}
							}
          
							jQuery(document).ready(function () {
								jQuery('.filed_label').each(function() {
									if(document.getElementById("frontend_submit_fields").value == document.getElementById("all_fields").value)
										document.getElementById("all_fields").checked = true;
									if(inArray(this.value, document.getElementById("frontend_submit_fields").value.split(","))) {
										this.checked = true;
									}
								});

								jQuery('.stats_filed_label').each(function() {
									if(document.getElementById("frontend_submit_stat_fields").value == document.getElementById("all_stats_fields").value)
										document.getElementById("all_stats_fields").checked = true;          
									if(inArray(this.value, document.getElementById("frontend_submit_stat_fields").value.split(","))) {
										this.checked = true;		
									}              
								});
              
								jQuery(document).on('change','input[name="all_fields"]',function() {
									jQuery('.filed_label').prop("checked" , this.checked);
								});

								jQuery(document).on('change','input[name="all_stats_fields"]',function() {
									jQuery('.stats_filed_label').prop("checked" , this.checked);
								});
							});
						</script>
						<style>
						li{
							list-style-type: none;
						}

						.simple_table {
							padding-left: 0px !important;
						}

						.simple_table input, .simple_table label, .simple_table img {
							display:inline-block !important;
							float:none !important;
						}
						</style>
						<fieldset class="adminform">
							<legend>Fields to hide in frontend submissions</legend>
							<?php if(count($label_titles_for_submissions)): ?>
							<table style="margin-left:-3px;">
							  <tr>
								<td> 
								  <label>Select fields:</label>
								</td>
								<td  class="simple_table">
								  <ul id="form_fields">
									<li>
									<input type="checkbox" name="all_fields" id="all_fields" value="submit_id,<?php echo implode(',',$labels_id_for_submissions)."," . ($payment_info ? "payment_info" : ""); ?>" onclick="checked_labels('filed_label')" disabled/>
									<label for="all_fields">Select All</label>
									</li>
									<?php 
									echo "<li><input type=\"checkbox\" id=\"submit_id\" name=\"submit_id\" value=\"submit_id\" class=\"filed_label\"  onclick=\"checked_labels('filed_label')\" disabled><label for=\"submit_id\">ID</label></li>";	
									  
									for($i=0, $n=count($label_titles_for_submissions); $i < $n ; $i++)     
									{
									  $field_label = $label_titles_for_submissions[$i];

									  echo "<li><input type=\"checkbox\" id=\"filed_label".$i."\" name=\"filed_label".$i."\" value=\"".$labels_id_for_submissions[$i]."\" class=\"filed_label\" onclick=\"checked_labels('filed_label')\" disabled><label for=\"filed_label".$i."\">".(strlen($field_label) > 80 ? substr ($field_label ,0, 80).'...' : $field_label)."</label></li>";
										   
									}
									if($payment_info)
									echo "<li><input type=\"checkbox\" id=\"payment_info\" name=\"payment_info\" value=\"payment_info\" class=\"filed_label\" onclick=\"checked_labels('filed_label')\" disabled><label for=\"payment_info\">Payment Info</label></li>";
									?>
								  </ul>
								  <input type="hidden" name="frontend_submit_fields" value="<?php echo $row->frontend_submit_fields ?>" id="frontend_submit_fields" />
								</td>	
							  </tr>
							  <?php if($stats_labels): ?>
							  <tr id="stats">
								<td> 
								  <label>Stats fields:</label>
								</td>
								<td class="simple_table">
								  <ul id="stats_fields">
									<li>
									<input type="checkbox" name="all_stats_fields" id="all_stats_fields" value="<?php echo implode(',',$stats_labels_ids).","; ?>" onclick="checked_labels('stats_filed_label')" disabled>
									<label for="all_stats_fields">Select All</label>
									</li>
									<?php 
									for($i=0, $n=count($stats_labels); $i < $n ; $i++)     
									{
									  $field_label = $stats_labels[$i];
									  echo "<li><input type=\"checkbox\" id=\"stats_filed_label".$i."\" name=\"stats_filed_label".$i."\" value=\"".$stats_labels_ids[$i]."\" class=\"stats_filed_label\" onclick=\"checked_labels('stats_filed_label')\" disabled><label for=\"stats_filed_label".$i."\" >".(strlen($field_label) > 80 ? substr ($field_label ,0, 80).'...' : $field_label)."</label></li>";
									}
									?>
								  </ul>
								  <input type="hidden" name="frontend_submit_stat_fields" value="<?php echo $row->frontend_submit_stat_fields ?>" id="frontend_submit_stat_fields" />
								</td>	
							  </tr>
							  <?php endif; ?>
							</table>
						  <?php endif; ?>
						</fieldset>
				</fieldset>
				<fieldset id="custom_fieldset" class="adminform fm_fieldset_deactive">
					<legend>Email Options</legend>
					<table class="admintable">
						<tr valign="top">
							<td style="width: 75px; vertical-align: middle;">
								<label>Send E-mail</label>
							</td>
							<td style="padding: 15px;">
								<button class="fm-checkbox-radio-button <?php echo $row->sendemail == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->sendemail; ?>">
									<span></span>
								</button>
								<input type="hidden" name="sendemail" value="<?php echo $row->sendemail; ?>"/>
							</td>
						</tr>
					</table>
					<fieldset class="adminform fm_mail_options">
						<legend>Email to Administrator</legend>
						<table class="admintable">
							<tr valign="top">
								<td class="fm_options_label">
									<label for="mailToAdd">Email to send submissions to</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mailToAdd" name="mailToAdd" style="width: 250px;" />
									<input type="hidden" id="mail" name="mail" value="<?php echo $row->mail . ($row->mail && (substr($row->mail, -1) != ',') ? ',' : ''); ?>" />
									<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version"); ?>" style="vertical-align: middle; cursor: pointer;" title="Add more emails" onclick="if (fm_check_email('mailToAdd')) {return false;};cfm_create_input('mail', 'mailToAdd', 'cfm_mail_div', '<?php echo WD_FMC_URL; ?>')" />
									<div id="cfm_mail_div">
										<?php
										$mail_array = explode(',', $row->mail);
										foreach ($mail_array as $mail) {
											if ($mail && $mail != ',') {
												?>
												<div class="fm_mail_input">
													<?php echo $mail; ?>
													<img src="<?php echo WD_FMC_URL; ?>/images/delete.png?ver=<?php echo get_option("wd_form_maker_version"); ?>" class="fm_delete_img" onclick="fm_delete_mail(this, '<?php echo $mail; ?>')" title="Delete Email" />
												</div>
												<?php
											}
										}
										?>
									</div>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="from_mail">Email From</label>
								</td>
								<td class="fm_options_value">
									<?php 
									$is_other = TRUE;
									for ($i = 0; $i < $fields_count - 1; $i++) {
										?>
										<div>
											 <input type="radio" name="from_mail" id="from_mail<?php echo $i; ?>" value="<?php echo (strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]); ?>"  <?php echo ((strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]) == $row->from_mail ? 'checked="checked"' : '' ); ?> onclick="wdhide('mail_from_other')" />
											<label for="from_mail<?php echo $i; ?>"><?php echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*')); ?></label>
										</div>
										<?php
										if(strlen($fields[$i])!=1) {
											if (substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->from_mail) {
												$is_other = FALSE;
											}
										}
										else {
											if($fields[$i] == $row->from_mail)
												$is_other=false;
										}
									}
									?>
									<div style="<?php echo ($fields_count == 1) ? 'display:none;' : ''; ?>">
										<input type="radio" id="other" name="from_mail" value="other" <?php echo ($is_other) ? 'checked="checked"' : ''; ?> onclick="wdshow('mail_from_other')" />
										<label for="other">Other</label>
									</div>
									<input type="text" style="width: <?php echo ($fields_count == 1) ? '250px' : '235px; margin-left: 15px' ?>; display: <?php echo ($is_other) ? 'block;' : 'none;'; ?>" id="mail_from_other" name="mail_from_other" value="<?php echo ($is_other) ? $row->from_mail : ''; ?>" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="from_name">From Name</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="from_name" name="from_name" value="<?php echo $row->from_name; ?>" style="width: 250px;" />
									<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version").''; ?>" onclick="document.getElementById('mail_from_labels').style.display='block';" style="vertical-align: middle; cursor: pointer;display:inline-block; margin:0px; float:none;">
									<?php 
									$choise = "document.getElementById('from_name')";
									echo '<div style="position:relative; top:-3px;"><div id="mail_from_labels" class="email_labels" style="display:none;">';
									echo "<a onClick=\"insertAtCursor(".$choise.",'username'); document.getElementById('mail_from_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
									for($i=0; $i<count($label_label); $i++) {
										if($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button" || $label_type[$i]=="type_file_upload" || $label_type[$i]=="type_send_copy" || $label_type[$i]=="type_matrix")			
										continue;		
										
										$param = htmlspecialchars(addslashes($label_label[$i]));			
										$fld_label = $param;
										if(strlen($fld_label)>30) {
											$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
											$fld_label = explode("\n", $fld_label);
											$fld_label = $fld_label[0] . ' ...';	
										}
									
										echo "<a onClick=\"insertAtCursor(".$choise.",'".$param."'); document.getElementById('mail_from_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">".$fld_label."</a>";
									}
									echo "<a onClick=\"insertAtCursor(".$choise.",'subid'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Submission ID</a>";	

									echo "<a onClick=\"insertAtCursor(".$choise.",'username'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
									echo '</div></div>';								
									?>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="reply_to">Reply to<br/>(if different from "Email From") </label>
								</td>
								<td class="fm_options_value">
									<?php 
									$is_other = TRUE;
									for ($i = 0; $i < $fields_count - 1; $i++) {
										?>
										<div>
											<input type="radio" name="reply_to" id="reply_to<?php echo $i; ?>" value="<?php echo (strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]); ?>"  <?php echo ((strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]) == $row->reply_to ? 'checked="checked"' : '' ); ?> onclick="wdhide('reply_to_other')" />
											<label for="reply_to<?php echo $i; ?>"><?php echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*')); ?></label>
										</div>
										<?php
										if(strlen($fields[$i])!=1) {
											if (substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*') + 15, strlen($fields[$i])) == $row->reply_to) {
												$is_other = FALSE;
											}
										}
										else {
											if($fields[$i] == $row->reply_to)
												$is_other=false;
										}
									}
									?>
									<div style="<?php echo ($fields_count == 1) ? 'display: none;' : ''; ?>">
										<input type="radio" id="other1" name="reply_to" value="other" <?php echo ($is_other) ? 'checked="checked"' : ''; ?> onclick="wdshow('reply_to_other')" />
										<label for="other1">Other</label>
									</div>
									<input type="text" style="width: <?php echo ($fields_count == 1) ? '250px' : '235px; margin-left: 15px'; ?>; display: <?php echo ($is_other) ? 'block;' : 'none;'; ?>" id="reply_to_other" name="reply_to_other" value="<?php echo ($is_other && $row->reply_to) ? $row->reply_to : ''; ?>" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> CC: </label>
								</td>
								<td class="fm_options_value">
									<input  type="text" id="mail_cc" name="mail_cc" value="<?php echo $row->mail_cc ?>" style="width:250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> BCC: </label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_bcc" name="mail_bcc" value="<?php echo $row->mail_bcc ?>" style="width:250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> Subject: </label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_subject" name="mail_subject" value="<?php echo $row->mail_subject ?>" style="width:250px;" />
									<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version").''; ?>" onclick="document.getElementById('mail_subject_labels').style.display='block';" style="vertical-align: middle;cursor: pointer; display:inline-block; margin:0px; float:none;">
									<?php 
									$choise = "document.getElementById('mail_subject')";
									echo '<div style="position:relative; top:-3px;"><div id="mail_subject_labels" class="email_labels" style="display:none;">';							
									for($i=0; $i<count($label_label); $i++)	{ 			
										if($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button" || $label_type[$i]=="type_file_upload" || $label_type[$i]=="type_send_copy" || $label_type[$i]=="type_matrix")			
										continue;		
										
										$param = htmlspecialchars(addslashes($label_label[$i]));			
										
										$fld_label = $param;
										if(strlen($fld_label)>30)
										{
											$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
											$fld_label = explode("\n", $fld_label);
											$fld_label = $fld_label[0] . ' ...';	
										}
									
										echo "<a onClick=\"insertAtCursor(".$choise.",'".$param."'); document.getElementById('mail_subject_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">".$fld_label."</a>";	

									}
									echo "<a onClick=\"insertAtCursor(".$choise.",'subid'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Submission ID</a>";	

									echo "<a onClick=\"insertAtCursor(".$choise.",'username'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
									echo '</div></div>';								
									?>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Mode: </label>
								</td>
								<td class="fm_options_value">
									<button name="mail_mode"class="fm-checkbox-radio-button <?php echo $row->mail_mode == 1 ? 'fm-text-yes' : 'fm-text-no' ?> medium" onclick="fm_change_radio_checkbox_text(this); return false;" value="<?php echo $row->mail_mode  ?>">
										<label><?php echo $row->mail_mode == 1 ? 'HTML' : 'Text' ?></label>
										<span></span>
									</button>
									<input type="hidden" name="mail_mode" value="<?php echo $row->mail_mode; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Attach File: </label>
								</td>
								<td class="fm_options_value">
									<div class="error_fm" style="padding: 5px; font-size: 14px;">File attach is disabled in free version.</div>
									<input type="hidden" name="mail_attachment" value="<?php echo $row->mail_attachment; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Email empty fields: </label>
								</td>
								<td class="fm_options_value">
									<button class="fm-checkbox-radio-button <?php echo $row->mail_emptyfields == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->mail_emptyfields; ?>">
										<span></span>
									</button>
									<input type="hidden" name="mail_emptyfields" value="<?php echo $row->mail_emptyfields; ?>"/>
								</td>
							</tr>
							<tr>
								<td class="fm_options_label" valign="top">
									<label>Custom Text in Email For Administrator</label>
								</td>
								<td class="fm_options_value">
									<div style="margin-bottom:5px">
										<?php
										$choise = "document.getElementById('script_mail')";
										for ($i = 0; $i < count($label_label); $i++) {
											if ($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button"  || $label_type[$i]=="type_send_copy")
											continue;
											
											$param = htmlspecialchars(addslashes($label_label[$i]));
											$fld_label = $param;
											if(strlen($fld_label)>30) {
												$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
												$fld_label = explode("\n", $fld_label);
												$fld_label = $fld_label[0] . ' ...';	
											}
														
											if($label_type[$i]=="type_file_upload")
												$fld_label .= '(as image)';
											?>
											<input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php echo $fld_label; ?>" onClick="insertAtCursor(<?php echo $choise; ?>, '<?php echo $param; ?>')" />
											<?php
										}
										?>
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Submission ID" onClick="insertAtCursor(<?php echo $choise; ?>,'subid')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Ip" onClick="insertAtCursor(<?php echo $choise; ?>,'ip')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Username" onClick="insertAtCursor(<?php echo $choise; ?>,'username')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="User Email" onClick="insertAtCursor(<?php echo $choise; ?>,'useremail')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php echo $choise; ?>, 'all')" />
									</div>
									<?php
									if (user_can_richedit()) {
										wp_editor($row->script_mail, 'script_mail', array('teeny' => FALSE, 'textarea_name' => 'script_mail', 'media_buttons' => FALSE, 'textarea_rows' => 5));
									}
									else {
										?>
										<textarea name="script_mail" id="script_mail" cols="20" rows="10" style="width:300px; height:450px;"><?php echo $row->script_mail; ?></textarea>
										<?php
									}
									?>
								</td>
							</tr>
						</table>
					</fieldset>
					<fieldset class="fm_mail_options">
						<legend>Email to User</legend>
						<table class="admintable">
							<tr valign="top">
								<td class="fm_options_label">
									<label for="mail">Send to</label>
								</td>
								<td class="fm_options_value">
									<?php 
										$fields = explode('*:*id*:*type_submitter_mail*:*type*:*', $row->form_fields);
										$fields_count = count($fields);
										if ($fields_count == 1) { ?>
											There is no email field
											<?php
										}
										else {
											for ($i = 0; $i < $fields_count - 1; $i++) {
												?>
												<div>
													<input type="checkbox" name="send_to<?php echo $i; ?>" id="send_to<?php echo $i; ?>" value="<?php echo (strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]); ?>"  <?php echo (is_numeric(strpos($row->send_to, '*'.(strlen($fields[$i])!=1 ? substr($fields[$i], strrpos($fields[$i], '*:*new_field*:*')+15, strlen($fields[$i])) : $fields[$i]).'*')) ? 'checked="checked"' : '' ); ?> style="margin: 0px 5px 0px 0px;" />
													<label for="send_to<?php echo $i; ?>"><?php echo substr($fields[$i + 1], 0, strpos($fields[$i + 1], '*:*w_field_label*:*')); ?></label>
												</div>
												<?php
											}
										}
									?>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="mail_from_user">Email From</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_from_user" name="mail_from_user" value="<?php echo $row->mail_from_user; ?>" style="width: 250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="mail_from_name_user">From Name</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_from_name_user" name="mail_from_name_user" value="<?php echo $row->mail_from_name_user; ?>" style="width: 250px;"/>
									<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version").''; ?>" onclick="document.getElementById('mail_from_name_user_labels').style.display='block';" style="vertical-align: middle;cursor: pointer; display:inline-block; margin:0px; float:none;">
									<?php 
									$choise = "document.getElementById('mail_from_name_user')";
									echo '<div style="position:relative; top:-3px;"><div id="mail_from_name_user_labels" class="email_labels" style="display:none;">';							
									for($i=0; $i<count($label_label); $i++)	{ 			
										if($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button" || $label_type[$i]=="type_file_upload" || $label_type[$i]=="type_send_copy")			
											continue;		
								  
										$param = htmlspecialchars(addslashes($label_label[$i]));			
										$fld_label = $param;
										if(strlen($fld_label)>30) {
											$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
											$fld_label = explode("\n", $fld_label);
											$fld_label = $fld_label[0] . ' ...';	
										}
								
										echo "<a onClick=\"insertAtCursor(".$choise.",'".$param."'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">".$fld_label."</a>";	
									}
									echo "<a onClick=\"insertAtCursor(".$choise.",'subid'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Submission ID</a>";	
									echo "<a onClick=\"insertAtCursor(".$choise.",'username'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
									echo '</div></div>';								
								?>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label for="reply_to_user">Reply to<br />(if different from "Email Form")</label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="reply_to_user" name="reply_to_user" value="<?php echo $row->reply_to_user; ?>" style="width:250px;"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> CC: </label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_cc_user" name="mail_cc_user" value="<?php echo $row->mail_cc_user ?>" style="width:250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> BCC: </label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_bcc_user" name="mail_bcc_user" value="<?php echo $row->mail_bcc_user ?>" style="width:250px;" />
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label">
									<label> Subject: </label>
								</td>
								<td class="fm_options_value">
									<input type="text" id="mail_subject_user" name="mail_subject_user" value="<?php echo $row->mail_subject_user ?>" style="width:250px;" />
									<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version").''; ?>" onclick="document.getElementById('mail_subject_user_labels').style.display='block';" style="vertical-align: middle; cursor: pointer; display:inline-block; margin:0px; float:none;">
									<?php 
									$choise = "document.getElementById('mail_subject_user')";
									echo '<div style="position:relative; top:-3px;"><div id="mail_subject_user_labels" class="email_labels" style="display:none;">';							
									for($i=0; $i<count($label_label); $i++)			
									{ 			
										if($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button" || $label_type[$i]=="type_file_upload" || $label_type[$i]=="type_send_copy")			
										continue;		
										
										$param = htmlspecialchars(addslashes($label_label[$i]));			
										
										$fld_label = $param;
										if(strlen($fld_label)>30)
										{
											$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
											$fld_label = explode("\n", $fld_label);
											$fld_label = $fld_label[0] . ' ...';	
										}
									
										echo "<a onClick=\"insertAtCursor(".$choise.",'".$param."'); document.getElementById('mail_subject_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">".$fld_label."</a>";	

									}
									echo "<a onClick=\"insertAtCursor(".$choise.",'subid'); document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Submission ID</a>";	

									echo "<a onClick=\"insertAtCursor(".$choise.",'username'); 			document.getElementById('mail_from_name_user_labels').style.display='none';\" style=\"display:block; text-decoration:none;\">Username</a>";
									echo '</div></div>';								
									?>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Mode: </label>
								</td>
								<td class="fm_options_value">
									<button name="mail_mode_user" class="fm-checkbox-radio-button <?php echo $row->mail_mode_user == 1 ? 'fm-text-yes' : 'fm-text-no' ?> medium" onclick="fm_change_radio_checkbox_text(this); return false;" value="<?php echo $row->mail_mode_user == 1 ? '1' : '0' ?>">
										<label><?php echo $row->mail_mode_user == 1 ? 'HTML' : 'Text' ?></label>
										<span></span>
									</button>
									<input type="hidden" name="mail_mode_user" value="<?php echo $row->mail_mode_user; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Attach File: </label>
								</td>
								<td class="fm_options_value">
									<div class="error_fm" style="padding: 5px; font-size: 14px;">File attach is disabled in free version.</div>
									<input type="hidden" name="mail_attachment_user" value="<?php echo $row->mail_attachment_user; ?>"/>
								</td>
							</tr>
							<tr valign="top">
								<td class="fm_options_label" style="vertical-align: middle;">
									<label> Email verification: </label>
								</td>
								<td class="fm_options_value">
									<button name="mail_verify" class="fm-checkbox-radio-button <?php echo $row->mail_verify == 1 ? 'fm-yes' : 'fm-no' ?>" onclick="fm_change_radio(this); return false;" value="<?php echo $row->mail_verify; ?>">
										<span></span>
									</button>
									<input type="hidden" name="mail_verify" value="<?php echo $row->mail_verify; ?>"/>
								</td>
							</tr>
							<tr valign="top" class="expire_link" <?php echo ($row->mail_verify==0 ? 'style="display:none;"' : '')?>>
								<td class="fm_options_label" valign="top">
									<label> Verification link expires in: </label>
								</td>
								<td class="fm_options_value">
									<input class="inputbox" type="text" name="mail_verify_expiretime" maxlength="10"  value = "<?php echo ($row->mail_verify_expiretime ? $row->mail_verify_expiretime : 0); ?>" style="width:95px;" onkeypress="return check_isnum_point(event)"/><small> -- hours (0 - never expires).</small>
								</td>
							</tr>
							<tr>
								<td class="fm_options_label" valign="top">
									<label>Custom Text in Email For User</label>
								</td>
								<td class="fm_options_value">
									<div style="margin-bottom:5px">
										<?php
										$choise = "document.getElementById('script_mail_user')";
										for ($i = 0; $i < count($label_label); $i++) {
											if ($label_type[$i] == "type_submit_reset" || $label_type[$i] == "type_editor" || $label_type[$i] == "type_map" || $label_type[$i] == "type_mark_map" || $label_type[$i] == "type_captcha" || $label_type[$i] == "type_recaptcha" || $label_type[$i] == "type_button" || $label_type[$i] == "type_file_upload" || $label_type[$i] == "type_send_copy") 
											continue;
											
											$param = htmlspecialchars(addslashes($label_label[$i]));
											$fld_label = $param;
											if(strlen($fld_label)>30) {
												$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
												$fld_label = explode("\n", $fld_label);
												$fld_label = $fld_label[0] . ' ...';	
											}
											if($label_type[$i]=="type_file_upload")
												$fld_label .= '(as image)';
											?>
											<input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php echo $fld_label; ?>" onClick="insertAtCursor(<?php echo $choise; ?>, '<?php echo $param; ?>')" />
											<?php
										}
										?>
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Submission ID" onClick="insertAtCursor(<?php echo $choise; ?>,'subid')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Ip" onClick="insertAtCursor(<?php echo $choise; ?>,'ip')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Username" onClick="insertAtCursor(<?php echo $choise; ?>,'username')" />
										<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="User Email" onClick="insertAtCursor(<?php echo $choise; ?>,'useremail')" />
										<input style="border: 1px solid silver; font-size: 10px; margin:3px;" type="button" value="All fields list" onClick="insertAtCursor(<?php echo $choise; ?>, 'all')" />
										<div class="verification_div" <?php echo ($row->mail_verify==0 ? 'style="display:none;"' : '')?>><input style="border: 1px solid silver; font-size: 10px; margin:3px;" type="button" value="Verification link" onClick="insertAtCursor(<?php echo $choise; ?>,'Verification link')" /> </div>
									</div>
									<?php
									if (user_can_richedit()) {
										wp_editor($row->script_mail_user, 'script_mail_user', array('teeny' => FALSE, 'textarea_name' => 'script_mail_user', 'media_buttons' => FALSE, 'textarea_rows' => 5));
									}
									else {
										?>
										<textarea name="script_mail_user" id="script_mail_user" cols="20" rows="10" style="width:300px; height:450px;"><?php echo $row->script_mail_user; ?></textarea>
										<?php
									}
									?>
								</td>
							</tr>
						</table>
					</fieldset>
				</fieldset>
				<fieldset id="actions_fieldset" class="adminform fm_fieldset_deactive">
					<legend>Actions after submission</legend>
					<table class="admintable">
						<tr valign="top">
							<td class="fm_options_label">
								<label>Action type</label>
							</td>
							<td class="fm_options_value">
								<div>
									<input type="radio" name="submit_text_type" id="text_type_none" onclick="set_type('none')" value="1" <?php echo ($row->submit_text_type != 2 && $row->submit_text_type != 3 && $row->submit_text_type != 4 && $row->submit_text_type != 5) ? "checked" : ""; ?> />
									<label for="text_type_none">Stay on Form</label>
								</div>
								<div>
									<input type="radio" name="submit_text_type" id="text_type_post" onclick="set_type('post')" value="2" <?php echo ($row->submit_text_type == 2) ? "checked" : ""; ?> />
									<label for="text_type_post">Post</label>
								</div>
								<div>
									<input type="radio" name="submit_text_type" id="text_type_page" onclick="set_type('page')" value="5" <?php echo ($row->submit_text_type == 5) ? "checked" : ""; ?> />
									<label for="text_type_page">Page</label>
								</div>
								<div>
									<input type="radio" name="submit_text_type" id="text_type_custom_text" onclick="set_type('custom_text')" value="3" <?php echo ($row->submit_text_type == 3 ) ? "checked" : ""; ?> />
									<label for="text_type_custom_text">Custom Text</label>
								</div>
								<div>
									<input type="radio" name="submit_text_type" id="text_type_url" onclick="set_type('url')" value="4" <?php echo ($row->submit_text_type == 4) ? "checked" : ""; ?> />
									<label for="text_type_url">URL</label>
								</div>
							</td>
						</tr>
						<tr id="none" <?php echo (($row->submit_text_type == 2 || $row->submit_text_type == 3 || $row->submit_text_type == 4 || $row->submit_text_type == 5) ? 'style="display:none"' : ''); ?>>
							<td class="fm_options_label">
								<label>Stay on Form</label>
							</td>
							<td class="fm_options_value">
								<img src="<?php echo WD_FMC_URL . '/images/verified.png'; ?>" border="0">
							</td>
						</tr>
						<tr id="post" <?php echo (($row->submit_text_type != 2) ? 'style="display:none"' : ''); ?>>
							<td class="fm_options_label">
								<label for="post_name">Post</label>
							</td>
							<td class="fm_options_value">
								<select id="post_name" name="post_name">
									<option value="0">- Select Post -</option>
									<?php
									$args = array('posts_per_page'  => 10000);
									query_posts($args);
									while (have_posts()) : the_post(); ?>
									<option value="<?php $x = get_permalink(get_the_ID()); echo $x; ?>" <?php echo (($row->article_id == $x) ? 'selected="selected"' : ''); ?>><?php the_title(); ?></option>
									<?php
									endwhile;
									wp_reset_query();
									?>
								</select>
							</td>
						</tr>
						<tr id="page" <?php echo (($row->submit_text_type != 5) ? 'style="display:none"' : ''); ?>>
							<td class="fm_options_label">
								<label for="page_name">Page</label>
							</td>
							<td class="fm_options_value">
								<select id="page_name" name="page_name">
									<option value="0">- Select Page -</option>
									<?php
									$pages = get_pages();
									foreach ($pages as $page) {
										$page_id = get_page_link($page->ID);
										?>
										<option value="<?php echo $page_id; ?>" <?php echo (($row->article_id == $page_id) ? 'selected="selected"' : ''); ?>><?php echo $page->post_title; ?></option>
										<?php
									}
									wp_reset_query();
									?>
								</select>
							</td>
						</tr>
						<tr id="custom_text" <?php echo (($row->submit_text_type != 3) ? 'style="display: none;"' : ''); ?>>
							<td class="fm_options_label">
								<label for="submit_text">Text</label>
							</td>
							<td class="fm_options_value">
								<?php $choise = "document.getElementById('submit_text')"; 
								for ($i = 0; $i < count($label_label); $i++) {
									if ($label_type[$i]=="type_submit_reset" || $label_type[$i]=="type_editor" || $label_type[$i]=="type_map" || $label_type[$i]=="type_mark_map" || $label_type[$i]=="type_captcha"|| $label_type[$i]=="type_recaptcha" || $label_type[$i]=="type_button"  || $label_type[$i]=="type_send_copy" || $label_type[$i]=="type_file_upload")
									  continue;
									
									$param = htmlspecialchars(addslashes($label_label[$i]));
									$fld_label = $param;
									if(strlen($fld_label)>30) {
										$fld_label = wordwrap(htmlspecialchars(addslashes($label_label[$i])), 30);
										$fld_label = explode("\n", $fld_label);
										$fld_label = $fld_label[0] . ' ...';	
									}

									?>
									<input style="border: 1px solid silver; font-size: 10px;" type="button" value="<?php echo $fld_label; ?>" onClick="insertAtCursor(<?php echo $choise; ?>, '<?php echo $param; ?>')" />
									<?php
								}
								?>
								<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Submission ID" onClick="insertAtCursor(<?php echo $choise; ?>,'subid')" />
								<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Ip" onClick="insertAtCursor(<?php echo $choise; ?>,'ip')" />
								<input style="border: 1px solid silver; font-size: 10px; margin:3px;" type="button" value="User Id" onClick="insertAtCursor(<?php echo $choise; ?>, 'userid')" />
								<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="Username" onClick="insertAtCursor(<?php echo $choise; ?>,'username')" />
								<input style="border: 1px solid silver; font-size: 10px; margin: 3px;" type="button" value="User Email" onClick="insertAtCursor(<?php echo $choise; ?>,'useremail')" />
								<?php
								if (user_can_richedit()) {
									wp_editor($row->submit_text, 'submit_text', array('teeny' => FALSE, 'textarea_name' => 'submit_text', 'media_buttons' => FALSE, 'textarea_rows' => 5));
								}
									else {
										?>
										<textarea cols="36" rows="5" id="submit_text" name="submit_text" style="resize: vertical;">
											<?php echo $row->submit_text; ?>
										</textarea>
										<?php
									}
									?>
								</td>
							</tr>
						<tr id="url" <?php echo (($row->submit_text_type != 4 ) ? 'style="display:none"' : ''); ?>>
							<td class="fm_options_label">
								<label for="url">URL</label>
							</td>
							<td class="fm_options_value">
								<input type="text" id="url" name="url" style="width:300px" value="<?php echo $row->url; ?>" />
							</td>
						</tr>
					</table>
				</fieldset>
				<fieldset id="payment_fieldset" class="adminform fm_fieldset_deactive">
					<legend>Payment Options</legend>
					<table class="admintable">
						<tr>
							<td colspan="2">
								<div class="error_fm" style="padding: 5px; font-size: 14px;">Paypal Options are disabled in free version.</div>
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label>Turn Paypal On</label>
							</td>
							<td class="fm_options_value">
								<button name="paypal_mode" class="fm-checkbox-radio-button <?php echo $row->paypal_mode == 1 ? 'fm-text-yes' : 'fm-text-no' ?> small" onclick="fm_change_radio_checkbox_text(this); return false;" value="<?php echo $row->paypal_mode == 1 ? '1' : '0' ?>" disabled="disabled">
									<label><?php echo $row->paypal_mode == 1 ? 'On' : 'Off' ?></label>
									<span></span>
								</button>
								<input type="hidden" name="paypal_mode" value="<?php echo $row->paypal_mode; ?>"/>
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label>Checkout Mode</label>
							</td>
							<td class="fm_options_value">
								<button name="checkout_mode" class="fm-checkbox-radio-button <?php echo $row->checkout_mode == 1 ? 'fm-text-yes' : 'fm-text-no' ?> large" onclick="fm_change_radio_checkbox_text(this); return false;" value="<?php echo $row->checkout_mode == 1 ? '1' : '0' ?>" disabled="disabled">
									<label><?php echo $row->checkout_mode == 1 ? 'Production' : 'Testmode' ?></label>
									<span></span>
								</button>
								<input type="hidden" name="checkout_mode" value="<?php echo $row->checkout_mode; ?>"/>
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="paypal_email">Paypal email</label>
							</td>
							<td class="fm_options_value">
								<input type="text" name="paypal_email" id="paypal_email" value="<?php echo $row->paypal_email; ?>" class="text_area" style="width:250px" disabled="disabled">
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="payment_currency">Payment Currency</label>
							</td>
							<td class="fm_options_value">
								<select id="payment_currency" name="payment_currency" disabled="disabled">
									<option value="USD" <?php echo (($row->payment_currency == 'USD') ? 'selected' : ''); ?>>$ &#8226; U.S. Dollar</option>
									<option value="EUR" <?php echo (($row->payment_currency == 'EUR') ? 'selected' : ''); ?>>&#8364; &#8226; Euro</option>
									<option value="GBP" <?php echo (($row->payment_currency == 'GBP') ? 'selected' : ''); ?>>&#163; &#8226; Pound Sterling</option>
									<option value="JPY" <?php echo (($row->payment_currency == 'JPY') ? 'selected' : ''); ?>>&#165; &#8226; Japanese Yen</option>
									<option value="CAD" <?php echo (($row->payment_currency == 'CAD') ? 'selected' : ''); ?>>C$ &#8226; Canadian Dollar</option>
									<option value="MXN" <?php echo (($row->payment_currency == 'MXN') ? 'selected' : ''); ?>>Mex$ &#8226; Mexican Peso</option>
									<option value="HKD" <?php echo (($row->payment_currency == 'HKD') ? 'selected' : ''); ?>>HK$ &#8226; Hong Kong Dollar</option>
									<option value="HUF" <?php echo (($row->payment_currency == 'HUF') ? 'selected' : ''); ?>>Ft &#8226; Hungarian Forint</option>
									<option value="NOK" <?php echo (($row->payment_currency == 'NOK') ? 'selected' : ''); ?>>kr &#8226; Norwegian Kroner</option>
									<option value="NZD" <?php echo (($row->payment_currency == 'NZD') ? 'selected' : ''); ?>>NZ$ &#8226; New Zealand Dollar</option>
									<option value="SGD" <?php echo (($row->payment_currency == 'SGD') ? 'selected' : ''); ?>>S$ &#8226; Singapore Dollar</option>
									<option value="SEK" <?php echo (($row->payment_currency == 'SEK') ? 'selected' : ''); ?>>kr &#8226; Swedish Kronor</option>
									<option value="PLN" <?php echo (($row->payment_currency == 'PLN') ? 'selected' : ''); ?>>zl &#8226; Polish Zloty</option>
									<option value="AUD" <?php echo (($row->payment_currency == 'AUD') ? 'selected' : ''); ?>>A$ &#8226; Australian Dollar</option>
									<option value="DKK" <?php echo (($row->payment_currency == 'DKK') ? 'selected' : ''); ?>>kr &#8226; Danish Kroner</option>
									<option value="CHF" <?php echo (($row->payment_currency == 'CHF') ? 'selected' : ''); ?>>CHF &#8226; Swiss Francs</option>
									<option value="CZK" <?php echo (($row->payment_currency == 'CZK') ? 'selected' : ''); ?>>Kc &#8226; Czech Koruny</option>
									<option value="ILS" <?php echo (($row->payment_currency == 'ILS') ? 'selected' : ''); ?>>&#8362; &#8226; Israeli Sheqel</option>
									<option value="BRL" <?php echo (($row->payment_currency == 'BRL') ? 'selected' : ''); ?>>R$ &#8226; Brazilian Real</option>
									<option value="TWD" <?php echo (($row->payment_currency == 'TWD') ? 'selected' : ''); ?>>NT$ &#8226; Taiwan New Dollars</option>
									<option value="MYR" <?php echo (($row->payment_currency == 'MYR') ? 'selected' : ''); ?>>RM &#8226; Malaysian Ringgit</option>
									<option value="PHP" <?php echo (($row->payment_currency == 'PHP') ? 'selected' : ''); ?>>&#8369; &#8226; Philippine Peso</option>
									<option value="THB" <?php echo (($row->payment_currency == 'THB') ? 'selected' : ''); ?>>&#xe3f; &#8226; Thai Bahtv</option>
								</select>
							</td>
						</tr>
						<tr valign="top">
							<td class="fm_options_label">
								<label for="tax">Tax</label>
							</td>
							<td class="fm_options_value">
								<input type="text" name="tax" id="tax" value="<?php echo $row->tax; ?>" class="text_area" style="width: 40px;" onKeyPress="return check_isnum_point(event)" disabled="disabled"> %
							</td>
						</tr>
					</table>
				</fieldset>
				<fieldset id="javascript_fieldset" class="adminform fm_fieldset_deactive">
					<legend>JavaScript</legend>
					<table class="admintable">
						<tr valign="top">
							<td class="fm_options_label">
								<label for="javascript">Javascript</label>
							</td>
							<td class="fm_options_value" style="width:650px;">
								<textarea style="margin: 0px; height: 400px; width: 600px;" cols="60" rows="30" name="javascript" id="form_javascript"><?php echo $row->javascript; ?></textarea>
							</td>
						</tr>
					</table>
				</fieldset>
				<fieldset id="conditions_fieldset" class="adminform fm_fieldset_deactive">
					<?php 	
					$ids = array();
					$types = array();
					$labels = array();
					$paramss = array();
					$all_ids = array();
					$all_labels = array();

					$select_and_input = array("type_text", "type_password", "type_textarea", "type_name", "type_number", "type_phone", "type_submitter_mail", "type_address", "type_spinner", "type_checkbox", "type_radio", "type_own_select", "type_paypal_price", "type_paypal_select", "type_paypal_checkbox", "type_paypal_radio", "type_paypal_shipping");
					$select_type_fields = array("type_address", "type_checkbox", "type_radio", "type_own_select", "type_paypal_select", "type_paypal_checkbox", "type_paypal_radio", "type_paypal_shipping");
		
					$fields=explode('*:*new_field*:*',$row->form_fields);
					$fields 	= array_slice($fields,0, count($fields)-1);   
					foreach($fields as $field) {
						$temp=explode('*:*id*:*',$field);
						array_push($ids, $temp[0]);
						array_push($all_ids, $temp[0]);
						$temp=explode('*:*type*:*',$temp[1]);
						array_push($types, $temp[0]);
						$temp=explode('*:*w_field_label*:*',$temp[1]);
						array_push($labels, $temp[0]);
						array_push($all_labels, $temp[0]);
						array_push($paramss, $temp[1]);

					}
					
					foreach($types as $key=>$value){
						if(!in_array($types[$key],$select_and_input)){					
							unset($ids[$key]);						
							unset($labels[$key]);					
							unset($types[$key]);
							unset($paramss[$key]);					
						}
					}	

					$ids = array_values($ids);
					$labels = array_values($labels);
					$types = array_values($types);
					$paramss = array_values($paramss);
					
					$chose_ids = implode('@@**@@',$ids);
					$chose_labels = implode('@@**@@',$labels);
					$chose_types = implode('@@**@@',$types);
					$chose_paramss = implode('@@**@@',$paramss);
						
					$all_ids_cond = implode('@@**@@',$all_ids);
					$all_labels_cond = implode('@@**@@',$all_labels);

					$show_hide	= array();
					$field_label	= array();
					$all_any 	= array();
					$condition_params 	= array();
		
					$count_of_conditions=0;
					if($row->condition!="") {
						$conditions=explode('*:*new_condition*:*',$row->condition);
						$conditions 	= array_slice($conditions,0, count($conditions)-1); 
						$count_of_conditions = count($conditions);					

						foreach($conditions as $condition) {
							$temp=explode('*:*show_hide*:*',$condition);
							array_push($show_hide, $temp[0]);
							$temp=explode('*:*field_label*:*',$temp[1]);
							array_push($field_label, $temp[0]);
							$temp=explode('*:*all_any*:*',$temp[1]);
							array_push($all_any, $temp[0]);
							array_push($condition_params, $temp[1]);
						}
					}
					else {
						$show_hide[0]=1;
						$all_any[0]='and';
						$condition_params[0]='';
						if($all_ids)
						$field_label[0] = $all_ids[0];
					}
					?>
					<div>
						<button class="fm-button add-button large" onclick="add_condition('<?php echo $chose_ids; ?>', '<?php echo htmlspecialchars(addslashes($chose_labels)); ?>', '<?php echo $chose_types; ?>', '<?php echo htmlspecialchars(addslashes($chose_paramss)); ?>', '<?php echo $all_ids_cond; ?>', '<?php echo htmlspecialchars(addslashes($all_labels_cond)); ?>'); return false;">
							Add Condition
							<span></span>
						</button>
					</div>
						<?php
						for($k=0; $k<$count_of_conditions; $k++) {	
							if(in_array($field_label[$k],$all_ids)) : ?>
								<div id="condition<?php echo $k; ?>" class="fm-condition">
									<div id="conditional_fileds<?php echo $k; ?>">
										<select id="show_hide<?php echo $k; ?>" name="show_hide<?php echo $k; ?>" style="width:80px; ">
											<option value="1" <?php if($show_hide[$k]==1) echo 'selected="selected"'; ?>>show</option>
											<option value="0" <?php if($show_hide[$k]==0) echo 'selected="selected"'; ?>>hide</option>
										</select> 
										<select id="fields<?php echo $k; ?>" name="fields<?php echo $k; ?>" style="width:300px; " onChange="" >
											<?php 
											foreach($all_labels as $key => $value) { 	
												if($field_label[$k]==$all_ids[$key])
													$selected = 'selected="selected"';
												else
													$selected ='';
												echo '<option value="'.$all_ids[$key].'" '.$selected.'>'.$value.'</option>';
											}
											?>
										</select> 
										<span>if</span>
										<select id="all_any<?php echo $k; ?>" name="all_any<?php echo $k; ?>" style="width:60px; ">
											<option value="and" <?php if($all_any[$k]=="and") echo 'selected="selected"'; ?>>all</option>
											<option value="or" <?php if($all_any[$k]=="or") echo 'selected="selected"'; ?>>any</option>
										</select> 
										<span>of the following match:</span>	
										<img src="<?php echo WD_FMC_URL . '/images/add.png?ver='. get_option("wd_form_maker_version").''; ?>" title="add" onclick="add_condition_fields(<?php echo $k; ?>,'<?php echo $chose_ids; ?>', '<?php echo htmlspecialchars(addslashes($chose_labels)); ?>', '<?php echo $chose_types; ?>', '<?php echo htmlspecialchars(addslashes($chose_paramss)); ?>')" style="cursor: pointer; vertical-align: middle;">
										<img src="<?php echo WD_FMC_URL . '/images/page_delete.png?ver='. get_option("wd_form_maker_version").''; ?>" onclick="delete_condition('<?php echo $k; ?>')" style="cursor: pointer; vertical-align: middle;">
									</div>
								<?php 
								if($condition_params[$k]) {
									$_params = explode('*:*next_condition*:*',$condition_params[$k]);
									$_params = array_slice($_params,0, count($_params)-1); 
								
										foreach($_params as $key=>$_param) {
											$key_select_or_input ='';
											$param_values = explode('***',$_param);
											$multiselect = explode('@@@',$param_values[2]);
										
											if(in_array($param_values[0],$ids)): ?>
											<div id="condition_div<?php echo $k; ?>_<?php echo $key; ?>">
											<select id="field_labels<?php echo $k; ?>_<?php echo $key; ?>" onchange="change_choices(this.options[this.selectedIndex].id+'_<?php echo $key; ?>','<?php echo $chose_ids; ?>', '<?php echo $chose_types; ?>', '<?php echo htmlspecialchars(addslashes($chose_paramss)); ?>')" style="width:300px;"/>
												<?php 
												foreach($labels as $key1 => $value) 		
												{ 		
													if($param_values[0]==$ids[$key1])
													{
														$selected = 'selected="selected"';
														if ($types[$key1]=="type_checkbox" || $types[$key1]=="type_paypal_checkbox")
															$multiple = 'multiple="multiple" class="multiple_select"';
														else
															$multiple ='';
														
														$key_select_or_input = $key1;
													}	
													else
														$selected ='';
													if($field_label[$k]!=$ids[$key1])
													echo '<option id="'.$k.'_'.$key1.'" value="'.$ids[$key1].'" '.$selected.'>'.$value.'</option>';
											
												}
									
												?>	
											</select>
											
											<select id="is_select<?php echo $k; ?>_<?php echo $key; ?>" style="vertical-align: top; width:94px;">
											<option value="==" <?php if($param_values[1]=="==") echo 'selected="selected"'; ?>>is</option>
											<option value="!=" <?php if($param_values[1]=="!=") echo 'selected="selected"'; ?>>is not</option>
											<option value="%" <?php if($param_values[1]=="%") echo 'selected="selected"'; ?>>like</option>

											<option value="!%" <?php if($param_values[1]=="!%") echo 'selected="selected"'; ?>>not like</option>

											<option value="=" <?php if($param_values[1]=="=") echo 'selected="selected"'; ?>>empty</option>

											<option value="!" <?php if($param_values[1]=="!") echo 'selected="selected"'; ?>>not empty</option>

											</select>
											
											<?php if ($key_select_or_input !== '' && in_array($types[$key_select_or_input],$select_type_fields)) : ?>
											<select id="field_value<?php echo $k; ?>_<?php echo $key; ?>" <?php echo $multiple; ?> style="width: 200px;">
											<?php  
											switch($types[$key_select_or_input])
											{
												case "type_own_select":
												case "type_paypal_select":
													$w_size = explode('*:*w_size*:*',$paramss[$key_select_or_input]);	
												break;
												
												case "type_radio":
												case "type_checkbox":
												case "type_paypal_radio":
												case "type_paypal_checkbox":
												case "type_paypal_shipping":
													$w_size = explode('*:*w_flow*:*',$paramss[$key_select_or_input]);	
												break;	
											}	
											
												$w_choices = explode('*:*w_choices*:*',$w_size[1]);
												$w_choices_array = explode('***',$w_choices[0]);
												
												$w_choices_price = explode('*:*w_choices_price*:*',$w_choices[1]);
												$w_choices_price_array = explode('***',$w_choices_price[0]);
													
												for($m=0; $m<count($w_choices_array); $m++)	
												{
													if($types[$key_select_or_input]=="type_paypal_checkbox" || $types[$key_select_or_input]=="type_paypal_radio" || $types[$key_select_or_input]=="type_paypal_shipping" || $types[$key_select_or_input]=="type_paypal_select")
														$w_choice = $w_choices_array[$m].'*:*value*:*'.$w_choices_price_array[$m];
													else
														$w_choice = $w_choices_array[$m];
														
													if(in_array(esc_html($w_choice),$multiselect))
													{
														$selected = 'selected="selected"';
													}	
													else
														$selected ='';

								if(strpos($w_choices_array[$m], '[') === false && strpos($w_choices_array[$m], ']') === false && strpos($w_choices_array[$m], ':') === false) {
													echo '<option id="choise_'.$k.'_'.$m.'" value="'.$w_choice.'" '.$selected.'>'.$w_choices_array[$m].'</option>';
								}
										}
										
										if($types[$key_select_or_input]=="type_address")
										{
											$w_countries = array("","Afghanistan","Albania","Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe");	
											$w_options = '';
											foreach($w_countries as $w_country)
											{
												if(in_array($w_country,$multiselect))
												{
													$selected = 'selected="selected"';
												}	
												else
													$selected ='';
																
												echo '<option value="'.$w_country.'" '.$selected.'>'.$w_country.'</option>';
											}
										}
							
										?>	
									</select>
									<?php else : 
									if($key_select_or_input != '' && ($types[$key_select_or_input]=="type_number" || $types[$key_select_or_input]=="type_phone"))
										$onkeypress_function = "onkeypress='return check_isnum_space(event)'";
									else
										if($key_select_or_input != '' && $types[$key_select_or_input]=="type_paypal_price")
											$onkeypress_function = "onkeypress='return check_isnum_point(event)'";
										else
											$onkeypress_function = "";
									?>
									<input id="field_value<?php echo $k; ?>_<?php echo $key; ?>" type="text" value="<?php echo $param_values[2];?>" <?php echo $onkeypress_function; ?> style=" width: 200px;"><?php endif; ?>
									
									<img src="<?php echo WD_FMC_URL . '/images/delete.png?ver='. get_option("wd_form_maker_version").''; ?>" id="delete_condition<?php echo $k; ?>_<?php echo $key; ?>" onclick="delete_field_condition('<?php echo $k; ?>_<?php echo $key; ?>')" style="vertical-align: middle;">
									</div>
									<?php endif;
								}
							}

						?>
						</div>
						<?php endif; 
						} 
						?>
					<input type="hidden" id="condition" name="condition" value="<?php echo $row->condition; ?>" />	
				</fieldset>
				
				</div>
				<input type="hidden" name="boxchecked" value="0">
				<input type="hidden" name="fieldset_id" id="fieldset_id" value="<?php echo WDW_FMC_Library::get('fieldset_id', 'general'); ?>" />
				<input type="hidden" id="task" name="task" value=""/>
				<input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
			</form>
		<script>
		jQuery(window).load(function () {
			form_maker_options_tabs(jQuery("#fieldset_id").val());
			fm_popup();
			function hide_email_labels(event) {
				var e = event.toElement || event.relatedTarget;
				if (e.parentNode == this || e == this) {
					return;
				}
				this.style.display="none";
			}
			if(document.getElementById('mail_from_labels')) {
				document.getElementById('mail_from_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('mail_subject_labels')) {
				document.getElementById('mail_subject_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('mail_from_name_user_labels')) {
				document.getElementById('mail_from_name_user_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('mail_subject_user_labels')) {
				document.getElementById('mail_subject_user_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('post_title_labels')) {
				document.getElementById('post_title_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('post_tags_labels')) {
				document.getElementById('post_tags_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('post_featured_image_labels')) {
				document.getElementById('post_featured_image_labels').addEventListener('mouseout',hide_email_labels,true);
			}
			if(document.getElementById('dbox_upload_dir_labels')) {
				document.getElementById('dbox_upload_dir_labels').addEventListener('mouseout',hide_email_labels,true);
			}
		});
		function wd_fm_apply_options(task) {
			set_condition();
			fm_set_input_value('task', task);
			document.getElementById('adminForm').submit();
		}
		</script>
		<?php
	}

	public function form_layout($id) {
		$row = $this->model->get_row_data($id);
		$ids = array();
		$types = array();
		$labels = array();
		$fields = explode('*:*new_field*:*', $row->form_fields);
		$fields = array_slice($fields, 0, count($fields) - 1);
		foreach ($fields as $field) {
			$temp = explode('*:*id*:*', $field);
			array_push($ids, $temp[0]);
			$temp = explode('*:*type*:*', $temp[1]);
			array_push($types, $temp[0]);
			$temp = explode('*:*w_field_label*:*', $temp[1]);
			array_push($labels, $temp[0]);
		}
		?>
		<script>
		var form_front = '<?php echo addslashes($row->form_front);?>';
		var custom_front = '<?php echo addslashes($row->custom_front);?>';
		if (custom_front == '') {
			custom_front = form_front;
		}
		function submitbutton() {
			if (jQuery('#autogen_layout').is(':checked')) {
				jQuery('#custom_front').val(custom_front.replace(/\s+/g, ' ').replace(/> </g, '><'));
			}
			else {
				jQuery('#custom_front').val(editor.getValue().replace(/\s+/g, ' ').replace(/> </g, '><'));
			}
		}
		function insertAtCursor_form(myId, myLabel) {
			if (jQuery('#autogen_layout').is(':checked')) {
				alert("Uncheck the Auto-Generate Layout box.");
				return;
			}
			myValue = '<div wdid="' + myId + '" class="wdform_row">%' + myId + ' - ' + myLabel + '%</div>';
			line = editor.getCursor().line;
			ch = editor.getCursor().ch;
			text = editor.getLine(line);
			text1 = text.substr(0, ch);
			text2 = text.substr(ch);
			text = text1 + myValue + text2;
			editor.setLine(line, text);
			editor.focus();
		}
		function autogen(status) {
			if (status) {
				custom_front = editor.getValue();
				editor.setValue(form_front);
				editor.setOption('readOnly', true);
				autoFormat();
			}
			else {
				editor.setValue(custom_front);
				editor.setOption('readOnly', false);
				autoFormat();
			}
		}
		function autoFormat() {
			CodeMirror.commands["selectAll"](editor);
			editor.autoFormatRange(editor.getCursor(true), editor.getCursor(false));
			editor.scrollTo(0,0);
		}
		</script>

		<div class="fm_layout">
			<form action="admin.php?page=manage_fmc" method="post" name="adminForm" enctype="multipart/form-data">
				<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
				<div class="fm-layout-actions">
					<div class="fm-page-actions">
						<button class="fm-button save-button small" onclick="submitbutton(); fm_set_input_value('task', 'save_layout');">
							Save
							<span></span>
						</button>
						<button class="fm-button apply-button small" onclick="submitbutton(); fm_set_input_value('task', 'apply_layout');">
							Apply
							<span></span>
						</button>
						<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', 'cancel_options');">
							Cancel
							<span></span>
						</button>
					</div>
				</div>
				<div class="fm-layout-content">
					<h2 style="clear: both;">Description</h2>
					<p>To customize the layout of the form fields uncheck the Auto-Generate Layout box and edit the HTML.</p>
					<p>You can change positioning, add in-line styles and etc. Click on the provided buttons to add the corresponding field.<br /> This will add the following line:
					  <b><span class="cm-tag">&lt;div</span> <span class="cm-attribute">wdid</span>=<span class="cm-string">"example_id"</span> <span class="cm-attribute">class</span>=<span class="cm-string">"wdform_row"</span><span class="cm-tag">&gt;</span>%example_id - Example%<span class="cm-tag">&lt;/div&gt;</span></b>
					  , where <b><span class="cm-tag">&lt;div&gt;</span></b> is used to set a row.</p>
					<p>To return to the default settings you should check Auto-Generate Layout box.</p>
					<h3 style="color:red">Notice</h3>
					<p>Make sure not to publish the same field twice. This will cause malfunctioning of the form.</p>
					<hr/>
					<label for="autogen_layout" style="font-size: 20px; line-height: 45px; margin-left: 10px;">Auto Generate Layout? </label>
					<input type="checkbox" value="1" name="autogen_layout" id="autogen_layout" <?php echo (($row->autogen_layout) ? 'checked="checked"' : ''); ?> />
					<input type="hidden" name="custom_front" id="custom_front" value="" />
					<input type="hidden" id="task" name="task" value=""/>
					<input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>" />
					<br/>
					<?php
					foreach($ids as $key => $id) {
						if ($types[$key] != "type_section_break") {
							?>
							<button onClick="insertAtCursor_form('<?php echo $ids[$key]; ?>','<?php echo $labels[$key]; ?>')" class="fm_label_buttons" title="<?php echo $labels[$key]; ?>"><?php echo $labels[$key]; ?></button>
							<?php
						}
					}
					?>
				</form>	
			</div>
			<br /><br />
			<button class="fm_submit_layout button button-secondary button-hero" onclick="autoFormat()"><strong>Apply Source Formatting</strong>  <em>(ctrl-enter)</em></button>
			<textarea id="source" name="source" style="display: none;"></textarea>
		</div>
		<script>
		var editor = CodeMirror.fromTextArea(document.getElementById("source"), {
			lineNumbers: true,
			lineWrapping: true,
			mode: "htmlmixed",
			value: form_front
		});
		if (jQuery('#autogen_layout').is(':checked')) {
			editor.setOption('readOnly',  true);
			editor.setValue(form_front);
		}
		else {
			editor.setOption('readOnly',  false);
			editor.setValue(custom_front);
		}
		jQuery('#autogen_layout').click(function() {
			autogen(jQuery(this).is(':checked'));
		});
		autoFormat();
		</script>
		<?php
	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewWidget_fmc.php000060400000010041152435511120011527 0ustar00<?php

class FMViewWidget_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;

  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function display() {
  }

  function widget($args, $instance) {
    extract($args);
    $title = $instance['title'];
    $form_id = (isset($instance['form_id']) ? $instance['form_id'] : 0);
    // Before widget.
    echo $before_widget;
    // Title of widget.
    if ($title) {
      echo $before_title . $title . $after_title;
    }
    // Widget output.
    require_once(WD_FMC_DIR . '/frontend/controllers/FMControllerForm_maker_fmc.php');
    $controller_class = 'FMControllerForm_maker_fmc';
    $controller = new $controller_class();
    echo $controller->execute($instance['form_id']);
    // After widget.
    echo $after_widget;
  }
  
  // Widget Control Panel.
  function form($instance, $id_title, $name_title, $id_form_id, $name_form_id) {
     $defaults = array(
      'title' => '',
      'form_id' => 0
    );
    $instance = wp_parse_args((array)$instance, $defaults);
    global $wpdb; ?>
    <p>
      <label for="<?php echo $id_title; ?>">Title:</label>
      <input class="widefat" id="<?php echo $id_title; ?>" name="<?php echo $name_title; ?>" type="text" value="<?php echo $instance['title']; ?>"/>
      <label for="<?php echo $id_form_id; ?>">Select a form:</label>
      <select name="<?php echo $name_form_id; ?>" id="<?php echo $id_form_id; ?>" style="width:225px;text-align:center;">
        <option style="text-align:center" value="0">- Select a Form -</option>
        <?php
        $ids_Form_Maker = $this->model->get_gallery_rows_data();
        foreach ($ids_Form_Maker as $arr_Form_Maker) {
          ?>
          <option value="<?php echo $arr_Form_Maker->id; ?>" <?php if ($arr_Form_Maker->id == $instance['form_id']) {
            echo "SELECTED";
          } ?>><?php echo $arr_Form_Maker->title; ?></option>
          <?php }?>
      </select>
    </p>
    <?php
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFormcontactwdcaptcha.php000060400000011367152435511120013631 0ustar00<?php

class FMViewFormcontactwdcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
	
    if (isset($_GET['action']) && esc_html($_GET['action']) == 'formcontactwdcaptcha') {
      $i = (isset($_GET["i"]) ? esc_html($_GET["i"]) : '');
      $r2 = (isset($_GET["r2"]) ? (int) $_GET["r2"] : 0);
      $rrr = (isset($_GET["rrr"]) ? (int) $_GET["rrr"] : 0);
      $randNum = 0 + $r2 + $rrr;
      $digit = (isset($_GET["digit"]) ? (int) $_GET["digit"] : 6);
      $cap_width = $digit * 10 + 15;
      $cap_height = 26;
      $cap_quality = 100;
      $cap_length_min = $digit;
      $cap_length_max = $digit;
      $cap_digital = 1;
      $cap_latin_char = 1;
      function code_generic($_length, $_digital = 1, $_latin_char = 1) {
        $dig = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
        $lat = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
        $main = array();
        if ($_digital) {
          $main = array_merge($main, $dig);
        }
        if ($_latin_char) {
          $main = array_merge($main, $lat);
        }
        shuffle($main);
        $pass = substr(implode('', $main), 0, $_length);
        return $pass;
      }
      $l = rand($cap_length_min, $cap_length_max);
      $code = code_generic($l, $cap_digital, $cap_latin_char);
      if (session_id() == '' || (function_exists('session_status') && (session_status() == PHP_SESSION_NONE))) {
        @session_start();
      }

      $_SESSION[$i . '_wd_captcha_code'] = md5($code);
      $canvas = imagecreatetruecolor($cap_width, $cap_height);
      $c = imagecolorallocate($canvas, rand(150, 255), rand(150, 255), rand(150, 255));
      imagefilledrectangle($canvas, 0, 0, $cap_width, $cap_height, $c);
      $count = strlen($code);
      $color_text = imagecolorallocate($canvas, 0, 0, 0);
      for ($it = 0; $it < $count; $it++) {
        $letter = $code[$it];
        imagestring($canvas, 6, (10 * $it + 10), $cap_height / 4, $letter, $color_text);
      }
      for ($c = 0; $c < 150; $c++) {
        $x = rand(0, $cap_width - 1);
        $y = rand(0, 29);
        $col = '0x' . rand(0, 9) . '0' . rand(0, 9) . '0' . rand(0, 9) . '0';
        imagesetpixel($canvas, $x, $y, $col);
      }
      header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
      header('Cache-Control: no-store, no-cache, must-revalidate');
      header('Cache-Control: post-check=0, pre-check=0', FALSE);
      header('Pragma: no-cache');
      header('Content-Type: image/jpeg');
      imagejpeg($canvas, NULL, $cap_quality);
    }
    die('');
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/.htaccess000044400000000424152435511120007474 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>views/FMViewThemes_fmc.php000060400000026314152435511120011543 0ustar00<?php
class FMViewThemes_fmc {
	////////////////////////////////////////////////////////////////////////////////////////
	// Events                                                                             //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constants                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Variables                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	private $model;

	////////////////////////////////////////////////////////////////////////////////////////
	// Constructor & Destructor                                                           //
	////////////////////////////////////////////////////////////////////////////////////////
	public function __construct($model) {
	$this->model = $model;
	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
    $rows_data = $this->model->get_rows_data();
    $page_nav = $this->model->page_nav();
    $search_value = ((isset($_POST['search_value'])) ? esc_html($_POST['search_value']) : '');
    $search_select_value = ((isset($_POST['search_select_value'])) ? (int)$_POST['search_select_value'] : 0);
    $asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
	$order_by_array = array('id', 'title', 'default');
    $order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
    $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
    $ids_string = '';
    ?>
    <div class="fm-user-manual">
		This section allows you to create, edit form themes.
		<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
	</div>
	<div class="fm-upgrade-pro">
		<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
			<div class="fm-upgrade-img">
				UPGRADE TO PRO VERSION 
				<span></span>
			</div>
		</a>
	</div>
	<div class="fm-clear"></div>
    <form class="wrap" id="themes_form" method="post" action="admin.php?page=themes_fmc" style="width:99%;">
		<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
		<div class="fm-page-banner themes-banner">
			<div class="theme_icon">
			</div>
			<div class="fm-logo-title">Themes</div>
			<button class="fm-button add-button medium" style="margin-left: 31px;" onclick="fm_set_input_value('task', 'add'); fm_form_submit(event, 'themes_form');">
				<span></span>
				Add New
			</button>
			<div class="fm-page-actions">
				<button class="fm-button delete-button small" onclick="if (confirm('Do you want to delete selected item(s)?')) { fm_set_input_value('task', 'delete_all'); } else { return false; }">
					<span></span>
					Delete
				</button>
			</div>
		</div>	
		<div class="fm-clear"></div>		
		<div class="tablenav top">
			<?php
				WDW_FMC_Library::search('Title', $search_value, 'themes_form');
				WDW_FMC_Library::html_page_nav($page_nav['total'], $page_nav['limit'], 'themes_form');
			?>
		</div>
		<table class="wp-list-table widefat fixed pages">
			<thead>
				<th class="manage-column column-cb check-column table_small_col"><input id="check_all" type="checkbox" style="margin:0;"/></th>
				<th class="table_small_col <?php if ($order_by == 'id') { echo $order_class; } ?>">
					<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'id'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'id' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'themes_form')" href="">
					<span>ID</span><span class="sorting-indicator"></span></a>
				</th>
				<th class="<?php if ($order_by == 'title') { echo $order_class; } ?>">
					<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'title'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'title' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'themes_form')" href="">
					<span>Title</span><span class="sorting-indicator"></span></a>
				</th>
				<th class="table_big_col <?php if ($order_by == 'default') { echo $order_class; } ?>">
					<a onclick="fm_set_input_value('task', ''); fm_set_input_value('order_by', 'default'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'default' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'themes_form')" href="">
					<span>Default</span><span class="sorting-indicator"></span></a>
				</th>
				<th class="table_small_col">Edit</th>
				<th class="table_small_col">Delete</th>
			</thead>
			<tbody id="tbody_arr">
			<?php
				if ($rows_data) {
					foreach ($rows_data as $row_data) {
						$alternate = (!isset($alternate) || $alternate == 'class="alternate"') ? '' : 'class="alternate"';
						$default_image = (($row_data->default) ? 'default' : 'notdefault');
						$default = (($row_data->default) ? '' : 'setdefault');
						?>
						<tr id="tr_<?php echo $row_data->id; ?>" <?php echo $alternate; ?>>
							<td class="table_small_col check-column">
								<input id="check_<?php echo $row_data->id; ?>" name="check_<?php echo $row_data->id; ?>" type="checkbox"/>
							</td>
							<td class="table_small_col"><?php echo $row_data->id; ?></td>
							<td>
								<a onclick="fm_set_input_value('task', 'edit'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'themes_form')" href="" title="Edit"><?php echo $row_data->title; ?></a>
							</td>
							<td class="table_big_col">
								<?php if ($default != '') { ?>
									<a onclick="fm_set_input_value('task', '<?php echo $default; ?>'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'themes_form')" href="">
								<?php } ?>
									<img src="<?php echo WD_FMC_URL . '/images/' . $default_image . '.png?ver='. get_option("wd_form_maker_version").''; ?>" />
								<?php if ($default != '') { ?>
									</a>
								<?php } ?>
							</td>
							<td class="table_small_col">
								<button class="fm-icon edit-icon" onclick="fm_set_input_value('task', 'edit'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'themes_form');">
									<span></span>
								</button>
							</td>
							<td class="table_small_col">
								<button class="fm-icon delete-icon" onclick="if (confirm('Do you want to delete selected item(s)?')) { fm_set_input_value('task', 'delete'); fm_set_input_value('current_id', '<?php echo $row_data->id; ?>'); fm_form_submit(event, 'themes_form'); } else {return false;}">
									<span></span>
								</button>
							</td>
						</tr>
						<?php
						$ids_string .= $row_data->id . ',';
					}
				}
				?>
			</tbody>
		</table>
		<input id="task" name="task" type="hidden" value=""/>
		<input id="current_id" name="current_id" type="hidden" value=""/>
		<input id="ids_string" name="ids_string" type="hidden" value="<?php echo $ids_string; ?>"/>
		<input id="asc_or_desc" name="asc_or_desc" type="hidden" value="asc"/>
		<input id="order_by" name="order_by" type="hidden" value="<?php echo $order_by; ?>"/>
    </form>
    <?php
	}

	public function edit($id, $reset) {
		$row = $this->model->get_row_data($id, $reset);
		$page_title = (($id != 0) ? 'Edit theme ' . $row->title : 'Create new theme');
		?>
		<style>
		.CodeMirror {
			border: 1px solid #ccc;
			font-size: 12px;
			margin-bottom: 6px;
			background: white;
		}
		</style>
		<div class="fm-user-manual">
			This section allows you to create, edit form themes.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-2.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
			<div class="fm-upgrade-img">
				UPGRADE TO PRO VERSION 
				<span></span>
			</div>
		</a>
		</div>
		<div class="fm-clear"></div>
		<form class="wrap" method="post" action="admin.php?page=themes_fmc" style="width:99%;">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>     
			<div class="fm-page-header">
				<div class="fm-page-title">
					<?php echo $page_title; ?>
				</div>
				<div class="fm-page-actions">
					<button class="fm-button save-button small" onclick="if (fm_check_required('title', 'Title')) {return false;}; fm_set_input_value('task', 'save');">
						<span></span>
						Save
					</button>
					<button class="fm-button apply-button small" onclick="if (fm_check_required('title', 'Title')) {return false;}; fm_set_input_value('task', 'apply');">
						<span></span>
						Apply
					</button>
					<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', 'cancel');">
						<span></span>
						Cancel
					</button>
				</div>
			</div>

			<table style="clear:both;">
				<tbody>
					<tr>
						<td class="fm_label"><label for="title">Title: <span style="color:#FF0000;"> * </span> </label></td>
						<td><input type="text" id="title" name="title" value="<?php echo $row->title; ?>" class="fm_text_input" /></td>
					</tr>
					<tr>
						<td class="fm_label"><label for="css">Css: </label></td>
						<td style="width: 90%;"><textarea id="css" name="css" rows="30" style="width: 100%;"><?php echo htmlspecialchars($row->css) ?></textarea></td>
					</tr>
				</tbody>
			</table>
			<input type="hidden" id="task" name="task" value=""/>
			<input type="hidden" id="current_id" name="current_id" value="<?php echo $row->id; ?>"/>
			<input type="hidden" id="default" name="default" value="<?php echo $row->default; ?>"/>
		</form>
		<script>
			var editor = CodeMirror.fromTextArea(document.getElementById("css"), {
				lineNumbers: true,
				lineWrapping: true,
				mode: "css"
			});
      
			CodeMirror.commands["selectAll"](editor);
			editor.autoFormatRange(editor.getCursor(true), editor.getCursor(false));
			editor.scrollTo(0,0);      
		</script>
		<?php
	}

	////////////////////////////////////////////////////////////////////////////////////////
	// Getters & Setters                                                                  //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Private Methods                                                                    //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Listeners                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFromipinfoinpopup_fmc.php000060400000010532152435511120014034 0ustar00<?php

class FMViewFromipinfoinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
    $data_ip = ((isset($_GET['data_ip'])) ? esc_html(stripslashes($_GET['data_ip'])) : 0);
    $query = @unserialize(file_get_contents('http://ip-api.com/php/' . $data_ip));
    if ($query && $query['status'] == 'success' && $query['countryCode']) {
      $country_flag = '<img width="16px" src="' .  WD_FMC_URL . '/images/flags/' . strtolower($query['countryCode']) . '.png" class="sub-align" alt="' . $query['country'] . '" title="' . $query['country'] . '" />';
      $country = $query['country'] ;
      $countryCode = $query['countryCode'] ;
      $city = $query['city'];
      $timezone = $query['timezone'];
      $lat = $query['lat'];
      $lon = $query['lon'];
    }
    else {
      $country_flag = '';
      $country = '';
      $countryCode = '';
      $city = '';
      $timezone = '';
      $lat = '';
      $lon = '';
    }
    ?>
    <style>
      .admintable {
        height: 100%;
        margin: 0 auto;
        padding: 0;
        width: 100%;
      }
      table.admintable td.key, table.admintable td.paramlist_key {
        background-color: #F6F6F6;
        border-bottom: 1px solid #E9E9E9;
        border-right: 1px solid #E9E9E9;
        color: #666666;
        font-weight: bold;
        margin-right: 10px;
        text-align: right;
        width: 140px;
      }
    </style>
    <table class="admintable">
      <tr>
        <td class="key"><b>IP:</b></td><td><?php echo $data_ip; ?></td>
      </tr>
      <tr>
        <td class="key"><b>Country:</b></td><td><?php echo $country . ' ' . $country_flag; ?></td>
      </tr>
      <tr>
        <td class="key"><b>CountryCode:</b></td><td><?php echo $countryCode; ?></td>
      </tr>
	    <tr>
        <td class="key"><b>City:</b></td><td><?php echo $city; ?></td>
      </tr>
      <tr>
        <td class="key"><b>Timezone:</b></td><td><?php echo $timezone; ?></td>
      </tr>
      <tr>
        <td class="key"><b>Latitude:</b></td><td><?php echo $lat; ?></td>
      </tr>
      <tr>
        <td class="key"><b>Longitude:</b></td><td><?php echo $lon; ?></td>
      </tr>
    </table>
    <?php
    die();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFormcontactwindow.php000060400000036400152435511120013175 0ustar00<?php

class FMViewFormcontactwindow {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
    $rows = $this->model->get_form_data();
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Contact Form Maker</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
        <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
        <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>

        <?php
        wp_print_scripts('jquery');
        ?>
        <base target="_self">
      </head>
      <body id="link" onLoad="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" dir="ltr" class="forceColors">
        <div class="tabs" role="tablist" tabindex="-1">
          <ul>
            <li id="display_tab" class="current" role="tab" tabindex="0">
              <span>
                <a href="javascript:mcTabs.displayTab('display_tab','display_panel');" onMouseDown="return false;" tabindex="-1">Contact Form Maker</a>
              </span>
            </li>
            <li id="submissions_tab" class="" role="tab" tabindex="0">
              <span>
                <a href="javascript:mcTabs.displayTab('submissions_tab','submissions_panel');" onMouseDown="return false;" tabindex="-1">Submissions</a>
              </span>
            </li>
          </ul>
        </div>
        <style>
          .panel_wrapper {
            height: 220px !important;
          }
          .smaller_font {
            font-size: 12px !important;
            vertical-align: middle; 
            text-align: left;
          }
          .smaller_font ul li {
            display: flex !important;
          }
          .smaller_font ul {
            margin: 0 !important;
          }
        </style>
        <div class="panel_wrapper" style="overflow: hidden;">
          <div id="display_panel" class="panel current">
            <table>
              <tr>
                <td style="vertical-align: middle; text-align: left;">Select a Form</td>
                <td style="vertical-align: middle; text-align: left;">
                  <select name="form_maker_id" id="form_maker_id" style="width: 230px; text-align: left;">
                    <option value="- Select Form -" selected="selected">- Select a Form -</option>
                    <?php
                    foreach ($rows as $row) {
                      ?>
                    <option value="<?php echo $row->id; ?>"><?php echo $row->title; ?></option>
                      <?php
                    }
                    ?>
                  </select>
                </td>
              </tr>
            </table>
          </div>
          <div id="submissions_panel" class="panel">
            <div class="error" style="position: relative; padding: 5px; font-size: 20px; color: red; opacity: 1; font-weight: bolder;">Front end submissions are disabled in free version.</div>
            <div style="position: absolute; background: gray; width: 92%; height: 65%; opacity: 0.3;">
            </div>
            <table>
              <tr>
                <td class="smaller_font">Select a Form:</td>
                <td class="smaller_font">
                  <select name="submissions_id" id="submissions_id" style="width: 230px; text-align: left;">
                    <option value="- Select Form -" selected="selected">- Select a Form -</option>
                    <?php
                    foreach ($rows as $row) {
                      ?>
                    <option value="<?php echo $row->id; ?>"><?php echo $row->title; ?></option>
                      <?php
                    }
                    ?>
                  </select>
                </td>
              </tr>
              <tr>
                <td class="smaller_font">Select Date Range:</td>
                <td class="smaller_font">
                  <!--<label style="min-width:30px !important;">From:</label>-->
                  <input class="inputbox" type="text" name="startdate" id="startdate" size="10" maxlength="10" value="" />
                  <input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('startdate','%Y-%m-%d');" />
                  <label style="min-width:30px !important;">To:</label>
                  <input class="inputbox" type="text" name="enddate" id="enddate" size="10" maxlength="10" value="" />
                  <input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('enddate','%Y-%m-%d');" />
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <table>
                    <tr>
                      <td style="border-right: 1px solid black;">
                        <table>
                          <tr>
                            <td class="smaller_font" style="vertical-align: top;">Select fields:</td>
                            <td class="smaller_font">
                              <ul>
                                <li>
                                  <input type="checkbox" checked="checked" id="submit_date" name="submit_date" value="submit_date">
                                  <label for="submit_date">Submit Date</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="submitter_ip" name="submitter_ip" value="submitter_ip">
                                  <label for="submitter_ip">Submitter's IP Address</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="username" name="username" value="username">
                                  <label for="username">Submitter's Username</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="useremail" name="useremail" value="useremail">
                                  <label for="useremail">Submitter's Email Address</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="form_fields" name="form_fields" value="form_fields">
                                  <label for="form_fields">Form Fields</label>                                  
                                </li>
                                <li><label style="font-size: 10px; width: 160px;">You can hide specific form fields from Form General Options.</label></li>
                              </ul>
                            </td>
                          </tr>
                          <tr>
                            <td class="smaller_font" style="vertical-align: top;">Export to:</td>
                            <td class="smaller_font">
                              <ul>
                                <li>
                                  <input type="checkbox" checked="checked" id="csv" name="csv" value="csv">
                                  <label for="csv">CSV</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="xml" name="xml" value="xml">
                                  <label for="xml">XML</label>
                                </li>
                              </ul>
                            </td>
                          </tr>
                        </table>
                      </td>
                      <td style="vertical-align: top;">
                        <table>
                          <tr>
                            <td class="smaller_font" style="vertical-align: top;">Show:</td>
                            <td class="smaller_font">
                              <ul>
                                <li>
                                  <input type="checkbox" checked="checked" id="title" name="title" value="title">
                                  <label for="title">Title</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="search" name="search" value="search">
                                  <label for="search">Search</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="ordering" name="ordering" value="ordering">
                                  <label for="ordering">Ordering</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="entries" name="entries" value="entries">
                                  <label for="entries">Entries</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="views" name="views" value="views">
                                  <label for="views">Views</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="conversion_rate" name="conversion_rate" value="conversion_rate">
                                  <label for="conversion_rate">Conversion Rate</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="pagination" name="pagination" value="pagination">
                                  <label for="pagination">Pagination</label>
                                </li>
                                <li>
                                  <input type="checkbox" checked="checked" id="stats" name="stats" value="stats">
                                  <label for="stats">Statistics</label>
                                </li>
                              </ul>
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </div>
        <div class="mceActionPanel">
          <div style="float: left;">
            <input type="button" id="cancel" name="cancel" value="Cancel" onClick="tinyMCEPopup.close();"/>
          </div>
          <div style="float: right;">
            <input type="submit" id="insert" name="insert" value="Insert" onClick="form_maker_insert_shortcode();"/>
          </div>
        </div>
        <script type="text/javascript">
          var short_code = get_params("wd_contact_form");
          if (short_code) {
            if (!short_code['type']) {
              document.getElementById("form_maker_id").value = short_code['id'];
            }
          }
          // Get shortcodes attributes.
          function get_params(module_name) {
            var selected_text = tinyMCE.activeEditor.selection.getContent();
            var module_start_index = selected_text.indexOf("[" + module_name);
            var module_end_index = selected_text.indexOf("]", module_start_index);
            var module_str = "";
            if ((module_start_index == 0) && (module_end_index > 0)) {
              module_str = selected_text.substring(module_start_index + 1, module_end_index);
            }
            else {
              return false;
            }
            var params_str = module_str.substring(module_str.indexOf(" ") + 1);
            var key_values = params_str.split(" ");
            var short_code_attr = new Array();
            for (var key in key_values) {
              var short_code_index = key_values[key].split('=')[0];
              var short_code_value = key_values[key].split('=')[1];
              short_code_value = short_code_value.substring(1, short_code_value.length - 1);
              short_code_attr[short_code_index] = short_code_value;
            }
            return short_code_attr;
          }
          function form_maker_insert_shortcode() {
            if (document.getElementById('display_panel').className !== 'panel') {
              if (document.getElementById('form_maker_id').value == '- Select Form -') {
                tinyMCEPopup.close();
              }
              else {
                var tagtext;
              tagtext = '[wd_contact_form id="' + document.getElementById('form_maker_id').value + '"]';
                window.tinyMCE.execCommand('mceInsertContent', false, tagtext);
                tinyMCEPopup.close();
              }
            }            
            else {
              alert("Front end submissions are disabled in free version.");
            }
          }
        </script>
      </body>
    </html>
    <?php
    die();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewFormMakerPreview_fmc.php000060400000064160152435511120013544 0ustar00<?php

class FMViewFormMakerPreview_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;


  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
    $form_id = ((isset($_GET['form_id'])) ? esc_html(stripslashes($_GET['form_id'])) : 0);
    $form = (($form_id) ? $this->model->get_form($form_id) : '');
    wp_print_scripts('jquery');
    wp_print_scripts('jquery-ui-widget');
    wp_print_scripts('jquery-ui-slider');
    wp_print_scripts('jquery-ui-spinner');
	$fmc_settings = get_option('fmc_settings');
	$map_key = isset($fmc_settings['map_key']) ? $fmc_settings['map_key'] : '';
    ?>
    <script src="https://maps.google.com/maps/api/js?v=3.exp&key=<?php echo $map_key ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/if_gmap_front_end.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/calendar/calendar.js'; ?>" type="text/javascript"></script>
    <script src="<?php echo WD_FMC_URL . '/js/calendar/calendar_function.js'; ?>" type="text/javascript"></script>
    <link media="all" type="text/css" href="<?php echo WD_FMC_URL . '/css/calendar-jos.css'; ?>" rel="stylesheet">
    <link media="all" type="text/css" href="<?php echo WD_FMC_URL . '/css/jquery-ui-1.10.3.custom.css'; ?>" rel="stylesheet">
    <link media="all" type="text/css" href="<?php echo WD_FMC_URL . '/css/jquery-ui-spinner.css'; ?>" rel="stylesheet">
    <?php
    if (isset($_GET['test_theme'])) {
      wp_print_scripts('jquery-effects-shake');
      wp_register_script('main_div_front_end', WD_FMC_URL . '/js/main_div_front_end.js', array(), get_option("wd_form_maker_version"));
      $theme_id = esc_html(stripslashes($_GET['test_theme']));
      require_once (WD_FMC_DIR . '/frontend/controllers/FMControllerForm_maker_fmc.php');
      $controller = new FMControllerForm_maker_fmc();
      echo $controller->execute($form_id, $theme_id);
      die();
    }
    $theme_id = ((isset($_GET['id'])) ? esc_html(stripslashes($_GET['id'])) : '');
    $css = $this->model->get_theme_css($theme_id);
    $id = 'form_id_temp';
    ?>
    <script src="<?php echo WD_FMC_URL . '/js/main_front_end.js'; ?>"></script>
    <style>
      <?php
      echo str_replace('[SITE_ROOT]', WD_FMC_URL, $css);
      ?>
    </style>
    <div id="form_id_temppages" class="wdform_page_navigation" show_title="" show_numbers="" type=""></div>
    <form id="form_preview"><?php echo $form; ?></form>
    <?php
    if ($form) { // Preview from options page.
      die();
    }
    ?>
    <input type="hidden" id="counter<?php echo $id; ?>" value="" name="counter<?php echo $id; ?>" />
    <script>
      var plugin_url = "<?php echo WD_FMC_URL; ?>";
      /*JURI_ROOT = '<?php echo WD_FMC_URL . '/js' ?>';*/
      document.getElementById('form_preview').innerHTML = window.parent.document.getElementById('take').innerHTML;
      document.getElementById('form_id_temppages').setAttribute('show_title', window.parent.document.getElementById('pages').getAttribute('show_title'));
      document.getElementById('form_id_temppages').setAttribute('show_numbers', window.parent.document.getElementById('pages').getAttribute('show_numbers'));
      document.getElementById('form_id_temppages').setAttribute('type', window.parent.document.getElementById('pages').getAttribute('type'));
      document.getElementById('counterform_id_temp').value = window.parent.gen;
      form_view_count<?php echo $id ?>= 0;
      for (i = 1; i <= 30; i++) {
        if (document.getElementById('<?php echo $id ?>form_view' + i)) {
          form_view_count<?php echo $id ?>++;
          form_view_max<?php echo $id ?>= i;
          document.getElementById('<?php echo $id ?>form_view' + i).parentNode.removeAttribute('style');
        }
      }
      refresh_first();
      if (form_view_count<?php echo $id ?>> 1) {
        for (i = 1; i <= form_view_max<?php echo $id ?>; i++) {
          if (document.getElementById('<?php echo $id ?>form_view' + i)) {
            first_form_view<?php echo $id ?>= i;
            break;
          }
        }
        generate_page_nav(first_form_view<?php echo $id ?>, '<?php echo $id ?>', form_view_count<?php echo $id ?>, form_view_max<?php echo $id ?>);
      }
      function remove_add_(id) {
        attr_name = new Array();
        attr_value = new Array();
        var input = document.getElementById(id);
        atr = input.attributes;
        for (v = 0; v < 30; v++)
          if (atr[v]) {
            if (atr[v].name.indexOf("add_") == 0) {
              attr_name.push(atr[v].name.replace('add_', ''));
              attr_value.push(atr[v].value);
              input.removeAttribute(atr[v].name);
              v--;
            }
          }
        for (v = 0; v < attr_name.length; v++) {
          input.setAttribute(attr_name[v], attr_value[v])
        }
      }
      function refresh_first() {
        n = window.parent.gen;
        for (i = 0; i < n; i++) {
          if (document.getElementById(i)) {
            for (z = 0; z < document.getElementById(i).childNodes.length; z++) {
              if (document.getElementById(i).childNodes[z].nodeType == 3) {
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[z]);
              }
            }
            if (document.getElementById(i).getAttribute('type') == "type_map") {
              if_gmap_init(i);
              for (q = 0; q < 20; q++) {
                if (document.getElementById(i + "_elementform_id_temp").getAttribute("long" + q)) {
                  w_long = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("long" + q));
                  w_lat = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("lat" + q));
                  w_info = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("info" + q));
                  add_marker_on_map(i, q, w_long, w_lat, w_info, false);
                }
              }
            }
            if (document.getElementById(i).getAttribute('type') == "type_mark_map") {
              if_gmap_init(i);
              w_long = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("long" + 0));
              w_lat = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("lat" + 0));
              w_info = parseFloat(document.getElementById(i + "_elementform_id_temp").getAttribute("info" + 0));
              add_marker_on_map(i, 0, w_long, w_lat, w_info, true);
            }
            if (document.getElementById(i).getAttribute('type') == "type_captcha" || document.getElementById(i).getAttribute('type') == "type_recaptcha") {
              if (document.getElementById(i).childNodes[10]) {
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              }
              else {
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
                document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              }
              continue;
            }
            if (document.getElementById(i).getAttribute('type') == "type_section_break") {
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              continue;
            }
            if (document.getElementById(i).childNodes[10]) {
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[2]);
            }
            else {
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
              document.getElementById(i).removeChild(document.getElementById(i).childNodes[1]);
            }
          }
        }
        for (i = 0; i <= n; i++) {
          if (document.getElementById(i)) {
            type = document.getElementById(i).getAttribute("type");
            switch (type) {
              case "type_text":
              case "type_number":
              case "type_password":
              case "type_submitter_mail":
              case "type_own_select":
              case "type_country":
              case "type_hidden":
              case "type_map": {
                remove_add_(i + "_elementform_id_temp");
                break;
              }
              case "type_submit_reset": {
                remove_add_(i + "_element_submitform_id_temp");
                if (document.getElementById(i + "_element_resetform_id_temp")) {
                  remove_add_(i + "_element_resetform_id_temp");
                }
                break;
              }

              case "type_captcha": {
                remove_add_("_wd_captchaform_id_temp");
                remove_add_("_element_refreshform_id_temp");
                remove_add_("_wd_captcha_inputform_id_temp");
                break;
              }
              case "type_recaptcha": {
                remove_add_("wd_recaptchaform_id_temp");
                break;
              }
              case "type_file_upload": {
                remove_add_(i + "_elementform_id_temp");
                break;
              }
              case "type_textarea": {
                remove_add_(i + "_elementform_id_temp");
                break;
              }
              case "type_name": {
                if (document.getElementById(i + "_element_titleform_id_temp")) {
                  remove_add_(i + "_element_titleform_id_temp");
                  remove_add_(i + "_element_firstform_id_temp");
                  remove_add_(i + "_element_lastform_id_temp");
                  remove_add_(i + "_element_middleform_id_temp");
                }
                else {
                  remove_add_(i + "_element_firstform_id_temp");
                  remove_add_(i + "_element_lastform_id_temp");

                }
                break;
              }
              case "type_phone": {
                remove_add_(i + "_element_firstform_id_temp");
                remove_add_(i + "_element_lastform_id_temp");
                break;
              }
              case "type_address": {
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('street1')=='no')
                  remove_add_(i+"_street1form_id_temp");
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('street2')=='no')	
                  remove_add_(i+"_street2form_id_temp");
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('city')=='no')
                  remove_add_(i+"_cityform_id_temp");
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('state')=='no')
                  remove_add_(i+"_stateform_id_temp");
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('postal')=='no')
                  remove_add_(i+"_postalform_id_temp");
                if(document.getElementById(i+"_disable_fieldsform_id_temp").getAttribute('country')=='no')
                  remove_add_(i+"_countryform_id_temp");
                break;
              }
              case "type_checkbox":
              case "type_radio": {
                is = true;
                for (j = 0; j < 100; j++) {
                  if (document.getElementById(i + "_elementform_id_temp" + j)) {
                    remove_add_(i + "_elementform_id_temp" + j);
                  }
                }
                break;
              }
              case "type_button": {
                for (j = 0; j < 100; j++) {
                  if (document.getElementById(i + "_elementform_id_temp" + j)) {
                    remove_add_(i + "_elementform_id_temp" + j);
                  }
                }
                break;
              }
              case "type_time": {
                if (document.getElementById(i + "_ssform_id_temp")) {
                  remove_add_(i + "_ssform_id_temp");
                  remove_add_(i + "_mmform_id_temp");
                  remove_add_(i + "_hhform_id_temp");
                }
                else {
                  remove_add_(i + "_mmform_id_temp");
                  remove_add_(i + "_hhform_id_temp");
                }
                break;
              }
              case "type_date": {
                remove_add_(i + "_elementform_id_temp");
                remove_add_(i + "_buttonform_id_temp");
                break;
              }
              case "type_date_fields": {
                remove_add_(i + "_dayform_id_temp");
                remove_add_(i + "_monthform_id_temp");
                remove_add_(i + "_yearform_id_temp");
                break;
              }
              case "type_star_rating": {	
                remove_add_(i+"_elementform_id_temp");
                break;
              }
              case "type_scale_rating": {	
                remove_add_(i+"_elementform_id_temp");
                break;
              }
              case "type_spinner": {
                remove_add_(i+"_elementform_id_temp");
                var spinner_value = document.getElementById(i+"_elementform_id_temp").getAttribute( "aria-valuenow" );
                var spinner_min_value = document.getElementById(i+"_min_valueform_id_temp").value;
                var spinner_max_value = document.getElementById(i+"_max_valueform_id_temp").value;
                var spinner_step = document.getElementById(i+"_stepform_id_temp").value;
                jQuery( "#"+i+"_elementform_id_temp" ).removeClass( "ui-spinner-input" )
                  .prop( "disabled", false )
                  .removeAttr( "autocomplete" )
                  .removeAttr( "role" )
                  .removeAttr( "aria-valuemin" )
                  .removeAttr( "aria-valuemax" )
                  .removeAttr( "aria-valuenow" );
                span_ui= document.getElementById(i+"_elementform_id_temp").parentNode;
                span_ui.parentNode.appendChild(document.getElementById(i+"_elementform_id_temp"));
                span_ui.parentNode.removeChild(span_ui);
                jQuery("#"+i+"_elementform_id_temp")[0].spin = null;
                spinner = jQuery( "#"+i+"_elementform_id_temp" ).spinner();
                spinner.spinner( "value", spinner_value );
                jQuery( "#"+i+"_elementform_id_temp" ).spinner({ min: spinner_min_value});    
                jQuery( "#"+i+"_elementform_id_temp" ).spinner({ max: spinner_max_value});
                jQuery( "#"+i+"_elementform_id_temp" ).spinner({ step: spinner_step});
                break;
              }
              case "type_slider": {	
                remove_add_(i+"_elementform_id_temp");	
                var slider_value = document.getElementById(i+"_slider_valueform_id_temp").value;
                var slider_min_value = document.getElementById(i+"_slider_min_valueform_id_temp").value;
                var slider_max_value = document.getElementById(i+"_slider_max_valueform_id_temp").value;
                var slider_element_value = document.getElementById( i+"_element_valueform_id_temp" );
                var slider_value_save = document.getElementById( i+"_slider_valueform_id_temp" );
                document.getElementById(i+"_elementform_id_temp").innerHTML = "";
                document.getElementById(i+"_elementform_id_temp").removeAttribute( "class" );
                document.getElementById(i+"_elementform_id_temp").removeAttribute( "aria-disabled" );
                jQuery("#"+i+"_elementform_id_temp")[0].slide = null;	
                jQuery( "#"+i+"_elementform_id_temp").slider({
                  range: "min",
                  value: eval(slider_value),
                  min: eval(slider_min_value),
                  max: eval(slider_max_value),
                  slide: function( event, ui ) {	
                    slider_element_value.innerHTML = "" + ui.value ;
                    slider_value_save.value = "" + ui.value; 

                  }
                });
                break;
              }
              case "type_range": {	
                remove_add_(i+"_elementform_id_temp0");
                remove_add_(i+"_elementform_id_temp1");
                var spinner_value0 = document.getElementById(i+"_elementform_id_temp0").getAttribute( "aria-valuenow" );
                var spinner_step = document.getElementById(i+"_range_stepform_id_temp").value;
                jQuery( "#"+i+"_elementform_id_temp0" ).removeClass( "ui-spinner-input" )
                  .prop( "disabled", false )
                  .removeAttr( "autocomplete" )
                  .removeAttr( "role" )
                  .removeAttr( "aria-valuenow" );
                span_ui= document.getElementById(i+"_elementform_id_temp0").parentNode;
                span_ui.parentNode.appendChild(document.getElementById(i+"_elementform_id_temp0"));
                span_ui.parentNode.removeChild(span_ui);
                jQuery("#"+i+"_elementform_id_temp0")[0].spin = null;
                jQuery("#"+i+"_elementform_id_temp1")[0].spin = null;
                spinner0 = jQuery( "#"+i+"_elementform_id_temp0" ).spinner();
                spinner0.spinner( "value", spinner_value0 );
                jQuery( "#"+i+"_elementform_id_temp0" ).spinner({ step: spinner_step});
                var spinner_value1 = document.getElementById(i+"_elementform_id_temp1").getAttribute( "aria-valuenow" );
                jQuery( "#"+i+"_elementform_id_temp1" ).removeClass( "ui-spinner-input" )
                  .prop( "disabled", false )
                  .removeAttr( "autocomplete" )
                  .removeAttr( "role" )
                  .removeAttr( "aria-valuenow" );
                span_ui1= document.getElementById(i+"_elementform_id_temp1").parentNode;
                span_ui1.parentNode.appendChild(document.getElementById(i+"_elementform_id_temp1"));
                span_ui1.parentNode.removeChild(span_ui1);
                spinner1 = jQuery( "#"+i+"_elementform_id_temp1" ).spinner();
                spinner1.spinner( "value", spinner_value1 );
                jQuery( "#"+i+"_elementform_id_temp1" ).spinner({ step: spinner_step});
                break;
              }
              case "type_grading": {
                for (k=0; k<100; k++) {
                  if (document.getElementById(i+"_elementform_id_temp"+k)) {
                    remove_add_(i+"_elementform_id_temp"+k);
                  }
                }
                break;
              }                
              case "type_matrix": {
                remove_add_(i+"_elementform_id_temp");
                break;
              }
            }
          }
        }
        for (t = 1; t <= form_view_max<?php echo $id ?>; t++) {
          if (document.getElementById('form_id_tempform_view' + t)) {
            form_view_element = document.getElementById('form_id_tempform_view' + t);
            remove_whitespace(form_view_element);
            xy = form_view_element.childNodes.length - 2;
            for (z = 0; z <= xy; z++) {
              if (form_view_element.childNodes[z]) {
                if (form_view_element.childNodes[z].nodeType != 3) {
                  if (!form_view_element.childNodes[z].id) {
                    del = true;
                    GLOBAL_tr = form_view_element.childNodes[z];
                    //////////////////////////////////////////////////////////////////////////////////////////
                    for (x = 0; x < GLOBAL_tr.firstChild.childNodes.length; x++) {
                      table = GLOBAL_tr.firstChild.childNodes[x];
                      tbody = table.firstChild;
                      if (tbody.childNodes.length) {
                        del = false;
                      }
                    }
                    if (del) {
                      form_view_element.removeChild(form_view_element.childNodes[z]);
                    }
                  }
                }
              }
            }
          }
        }
        for (i = 1; i <= window.parent.form_view_max; i++) {
          if (document.getElementById('form_id_tempform_view' + i)) {
            document.getElementById('form_id_tempform_view' + i).parentNode.removeChild(document.getElementById('form_id_tempform_view_img' + i));
            document.getElementById('form_id_tempform_view' + i).removeAttribute('style');
          }
        }
      }
      function remove_whitespace(node) {
        var ttt;
        for (ttt = 0; ttt < node.childNodes.length; ttt++) {
          if (node.childNodes[ttt] && node.childNodes[ttt].nodeType == '3' && !/\S/.test(node.childNodes[ttt].nodeValue)) {
            node.removeChild(node.childNodes[ttt]);
            ttt--;
          }
          else {
            if (node.childNodes[ttt].childNodes.length) {
              remove_whitespace(node.childNodes[ttt]);
            }
          }
        }
        return;
      }
    </script>
    <?php
    die();
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewSubmissions_fmc.php000060400000603412152435511120012634 0ustar00<?php

class  FMViewSubmissions_fmc {
	////////////////////////////////////////////////////////////////////////////////////////
	// Events                                                                             //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constants                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Variables                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	private $model;

	////////////////////////////////////////////////////////////////////////////////////////
	// Constructor & Destructor                                                           //
	////////////////////////////////////////////////////////////////////////////////////////
	public function __construct($model) {
	$this->model = $model;
	}

	////////////////////////////////////////////////////////////////////////////////////////
	// Public Methods                                                                     //
	////////////////////////////////////////////////////////////////////////////////////////
	public function display($form_id) {
		
		
		global $wpdb;
		$forms = $this->model->get_form_titles();
		$statistics = $this->model->get_statistics($form_id);
		$labels_parameters = $this->model->get_labels_parameters($form_id);

		$sorted_labels_id = $labels_parameters[0]; 
		$sorted_label_types = $labels_parameters[1]; 
		$lists = $labels_parameters[2];
		$sorted_label_names = $labels_parameters[3]; 
		$sorted_label_names_original = $labels_parameters[4]; 
		$rows = ((isset($labels_parameters[5])) ? $labels_parameters[5] : NULL);
		$group_ids = ((isset($labels_parameters[6])) ? $labels_parameters[6] : NULL);
		$where_choices = $labels_parameters[7];	
		$order_by = (isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'group_id');
		$asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'asc') ? 'asc' : 'desc');
		$style_id = $this->model->hide_or_not($lists['hide_label_list'], '@submitid@'); 
		$style_date = $this->model->hide_or_not($lists['hide_label_list'], '@submitdate@');
		$style_ip = $this->model->hide_or_not($lists['hide_label_list'], '@submitterip@');

		$style_username = $this->model->hide_or_not($lists['hide_label_list'], '@submitterusername@');
		$style_useremail = $this->model->hide_or_not($lists['hide_label_list'], '@submitteremail@');

		$oder_class_default = "manage-column column-autor sortable desc";
		$oder_class = "manage-column column-title sorted " . $asc_or_desc; 
		$ispaypal = FALSE;
		$temp = array();
		$m = count($sorted_label_names);
		$n = count($rows);
		$group_id_s = array();	
		$group_id_s = $this->model->sort_group_ids(count($sorted_label_names),$group_ids);  
		$ka_fielderov_search = (($lists['ip_search'] || $lists['startdate'] || $lists['enddate'] || $lists['username_search'] || $lists['useremail_search'] || $lists['id_search']) ? TRUE : FALSE);
		$is_stats = false;
		$blocked_ips = $this->model->blocked_ips();
		
		if (defined('WD_FM_PDF') && is_plugin_active(constant('WD_FM_PDF'))) {
			require_once(WD_FM_PDF_DIR.'/model.php');
			$pdf_data = WD_FM_PDF_model::get_pdf_data($form_id);
		}
		$subs_count = $this->model->get_subs_count($form_id);
		$chosen_form_title = '';
		if ($forms) { 
			foreach($forms as $form) {
				if ($form_id == $form->id) { 
					$chosen_form_title = $form->title;
				}
			}
		}
		?>
		<script type="text/javascript">
			function export_submissions(type, limit) {
			var progressbar = jQuery( "#fm-progressbar" );
			var progressLabel = jQuery( ".fm-progress-label" );
		 
			progressbar.progressbar({
				max: <?php echo $subs_count; ?>
			});
			
			jQuery.ajax({
			    type: "POST",  
				url:"<?php echo add_query_arg(array('form_id' => $form_id, 'send_header' => 0), admin_url('admin-ajax.php')); ?>&action=generete_"+type+"_fmc&limitstart="+limit,
				beforeSend: function() {
					if(<?php echo $subs_count; ?> >= 1000 )
						jQuery('.fm_modal').show();
			    },
			    success: function(data) {
					if(limit < <?php echo $subs_count; ?>) {
						limit += 1000;
						export_submissions(type, limit);
						progressbar.progressbar( "value",  limit);
						loaded_percent = Math.round((progressbar.progressbar( "value" ) * 100)/ parseInt(<?php echo $subs_count; ?>));
						progressLabel.text( loaded_percent + ' %');
						progressbarValue = progressbar.find( ".fm-progress-label" );
						if( loaded_percent >= 46 ) {
							progressbarValue.css({
								"color": '#fff',
							});
						}
						else {
							progressbarValue.css({
								"color": '#444',
							});
						}
					}
					else{
						jQuery('.fm_modal').hide();
						progressbar.progressbar( "value",  0);
						progressLabel.text( 'Loading ...' );
						progressbarValue = progressbar.find( ".fm-progress-label" );
						progressbarValue.css({
							"color": '#444',
						});
						window.location = "<?php echo add_query_arg(array('form_id' => $form_id, 'send_header' => 1), admin_url('admin-ajax.php')); ?>&action=generete_"+type+"_fmc&limitstart="+limit;
					}
			    }
			});
		}
	
			function clickLabChBAll(ChBAll) {
				<?php
					if (isset($sorted_label_names)) {
						$templabels = array_merge(array(
							'submitid',
							'submitdate',
							'submitterip',
							'submitterusername',
							'submitteremail'
						), $sorted_labels_id);
						$sorted_label_names_for_check = array_merge(array(
							'ID',
							'Submit date',
							"Submitter's IP",
							"Submitter's Username",
							"Submitter's Email Address"
						), $sorted_label_names_original);
					}
					else {
						$templabels = array(
							'submitid',
							'submitdate',
							'submitterip',
							'submitterusername',
							'submitteremail'
						);
						$sorted_label_names_for_check = array(
							'ID',
							'Submit date',
							"Submitter's IP",
							'Submitter\'s Username',
							'Submitter\'s Email Address'
						);
					}
				?>
				if (ChBAll.checked) {
					document.forms.admin_form.hide_label_list.value = '';
					for (i = 0; i <= ChBAll.form.length; i++) {
						if (typeof(ChBAll.form[i]) != "undefined") {
							if (ChBAll.form[i].type == "checkbox") {
								ChBAll.form[i].checked = true;
							}
						}
					}
				}
				else {
					document.forms.admin_form.hide_label_list.value = '@<?php echo implode($templabels, '@@') ?>@' + '@payment_info@';
					for (i = 0; i <= ChBAll.form.length; i++) {
						if (typeof(ChBAll.form[i]) != "undefined") {
							if (ChBAll.form[i].type == "checkbox") {
								ChBAll.form[i].checked = false;
							}
						}
					}
				}
				renderColumns();
			}
			
			function remove_all() {
				if(document.getElementById('startdate'))
					document.getElementById('startdate').value='';
				if(document.getElementById('enddate'))
					document.getElementById('enddate').value='';
				if(document.getElementById('id_search'))
					document.getElementById('id_search').value='';
				if(document.getElementById('ip_search'))
					document.getElementById('ip_search').value='';
				if(document.getElementById('username_search'))
					document.getElementById('username_search').value='';
				if(document.getElementById('useremail_search'))
					document.getElementById('useremail_search').value='';
				<?php
				$n = count($rows);
				for ($i = 0; $i < count($sorted_label_names); $i++) {
					if ($sorted_label_types[$i] != "type_mark_map") { ?>
						document.getElementById('<?php echo $form_id . '_' . $sorted_labels_id[$i] . '_search'; ?>').value='';
						<?php
					}
				}
				?>
			}
			function show_hide_filter() {
				if (document.getElementById('fields_filter').style.display == "none") {
					document.getElementById('fields_filter').style.display = '';
				}
				else {
					document.getElementById('fields_filter').style.display = "none";
				}
				return false;
			}
			jQuery(document).ready(function () { 
				jQuery('.theme-detail').click(function () {
					jQuery(this).siblings('.themedetaildiv').toggle();
					return false;
				});
			});
		</script>
		<div class="fm_modal"> 
			<div id="fm-progressbar" >
				<div class="fm-progress-label">Loading...</div>
			</div> 
		</div> 
		<div class="export_progress">
			<span class="exp_count"><?php echo $subs_count; ?></span> left from <?php echo $subs_count; ?>
		</div> 
		<div id="sbox-overlay" onclick="toggleChBDiv(false);">
		</div>
		<div id="ChBDiv">
			<form action="#">
				<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
				<p style="font-weight: bold; font-size: 18px; margin-top: 0px;">Select Columns</p>
				<div class="fm_check_labels"><input type="checkbox" <?php echo ($lists['hide_label_list'] === '') ? 'checked="checked"' : ''; ?> onclick="clickLabChBAll(this)" id="ChBAll"/><label for="ChBAll"> All</label></div>
				<?php
				foreach ($templabels as $key => $curlabel) {
					if (strpos($lists['hide_label_list'], '@' . $curlabel . '@') === FALSE) {
						?>
						<div class="fm_check_labels"><input type="checkbox" checked="checked" onclick="clickLabChB('<?php echo $curlabel; ?>', this)" id="fm_check_id_<?php echo $curlabel; ?>" /><label for="fm_check_id_<?php echo $curlabel; ?>"> <?php echo stripslashes($sorted_label_names_for_check[$key]); ?></label></div>
						<?php
					}		  
					else {
						?>
						<div class="fm_check_labels"><input type="checkbox" onclick="clickLabChB('<?php echo $curlabel; ?>', this)" id="fm_check_id_<?php echo $curlabel; ?>"/><label for="fm_check_id_<?php echo $curlabel; ?>"> <?php echo stripslashes($sorted_label_names_for_check[$key]); ?></label></div>
						<?php  
					}
				}
				$ispaypal = FALSE;
				for ($i = 0; $i < count($sorted_label_names); $i++) {
					if ($sorted_label_types[$i] == 'type_paypal_payment_status') {
						$ispaypal = TRUE;
					}
				}
				if ($ispaypal) {
					?>
					<div class="fm_check_labels">
						<input type="checkbox" onclick="clickLabChB('payment_info', this)" id="fm_check_payment_info" <?php echo (strpos($lists['hide_label_list'], '@payment_info@') === FALSE) ? 'checked="checked"' : ''; ?> />
						<label for="fm_check_payment_info"> Payment Info</label>
					</div>
					<?php
				}
				?>
				<div style="text-align: center; padding-top: 20px;">
					<button onclick="toggleChBDiv(false); return false;" style="background: #4EC0D9; width: 78px; height: 32px; border: 1px solid #4EC0D9; border-radius: 0px; color: #fff; cursor: pointer;">Done</button>
				</div>
			</form>
		</div>
		<div class="fm-user-manual">
			This section allows you to view and manage form submissions.
			<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-7.html">Read More in User Manual</a>
		</div>
		<div class="fm-upgrade-pro">
			<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
				<div class="fm-upgrade-img">
					UPGRADE TO PRO VERSION 
					<span></span>
				</div>
			</a>
		</div>
		<div class="fm-clear"></div>
		<form action="admin.php?page=submissions_fmc" method="post" id="admin_form" name="admin_form">
			<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
			<input type="hidden" name="option" value="com_formmaker" />
			<input type="hidden" id="task" name="task" value="" />
			<input type="hidden" id="current_id" name="current_id" value="" />
			<input type="hidden" name="asc_or_desc" id="asc_or_desc" value="<?php echo $asc_or_desc; ?>" />
			<input type="hidden" name="order_by" id="order_by" value="<?php echo $order_by; ?>" />
			
			<div class="fm-submissions-page">
				<div class="submissions-actions">
					<div class="fm-form-title">
						<?php echo $chosen_form_title; ?>	
					</div>
					<div class="fm-page-actions">
						<button class="fm-button block-button small" onclick="fm_set_input_value('task', 'block_ip'); fm_form_submit(event, 'admin_form');">
							<span></span>
							Block IP
						</button>
						<button class="fm-button unblock-button medium" onclick="fm_set_input_value('task', 'unblock_ip'); fm_form_submit(event, 'admin_form');">
							<span></span>
							Unblock IP
						</button>
						<button class="fm-button delete-button small" onclick="if (confirm('Do you want to delete selected items?')) { fm_set_input_value('task', 'delete_all'); fm_form_submit(event, 'admin_form'); } else { return false; }">
							<span></span>
							Delete
						</button>
					</div>
				</div>
				<div class="submissions-toolbar">
					<div class="submissions-tools">
						<select name="form_id" id="form_id" onchange="document.admin_form.submit();">
							<option value="0" selected="selected"> - Select a Form - </option>
							<?php if ($forms) { 
								foreach($forms as $form) {
									?>
									<option value="<?php echo $form->id; ?>" <?php if ($form_id == $form->id) { echo 'selected="selected"'; }?>> <?php echo $form->title ?> </option>
									<?php
								}
							} ?>
						</select>
						<div class="fm-reports">
							<div class="fm-tools-button"><div class="fm-total_entries"><?php echo $statistics["total_entries"]; ?></div>Entries</div>
							<div class="fm-tools-button"><div class="fm-total_rate"><?php echo $statistics["conversion_rate"]; ?></div>Conversion Rate</div>
							<div class="fm-tools-button"><div class="fm-total_views"><?php echo $statistics["total_views"] ? $statistics["total_views"] : 0; ?></div>Views</div>
						</div>
						
						<div class="fm-export-tools">
							<span class="exp_but_span">Export to</span>
							&nbsp;
							<button class="fm-tools-button" onclick="export_submissions('csv', 0); return false;">
								CSV
							</button>
							<button class="fm-tools-button" onclick="export_submissions('xml', 0); return false;">
								XML
							</button>
						</div>
					</div>
				</div>
				<div class="tablenav top">
					<div class="fm-filters">
						<div class="fm-search-tools">
							<input type="hidden" name="hide_label_list" value="<?php echo $lists['hide_label_list']; ?>"> 
							<button class="fm-icon show-filter-icon" onclick="show_hide_filter(); return false;" title="Show Filters">
								<span></span>
							</button>
							<button class="fm-icon search-icon" onclick="fm_form_submit(event, 'admin_form'); return false;" title="Search">
							</button>
							<button class="fm-icon reset-icon" onclick="remove_all(); fm_form_submit(event, 'admin_form'); return false;" title="Reset">
							</button>
						</div>
						<div class="fm-add-remove">
							<?php if (isset($sorted_label_names)) { ?>
							<button class="fm-button" onclick="toggleChBDiv(true); return false;">
								Add/Remove Columns
							</button>
							<?php WDW_FMC_Library::html_page_nav($lists['total'], $lists['limit'], 'admin_form'); ?>
							<?php } ?>
							<input type="hidden" name="pagination_clicked" id="pagination_clicked" value=""/>
						</div>
					</div>
					<div class="fm-clear"></div>
				</div>
				
				<div class="fm-loading-container" style="display:none;">
					<div class="fm-loading-content">
					</div>
				</div>
				<div class="submit_content" id="fm-scroll" style="width: 100%;">
					<table class="wp-list-table widefat fixed posts table_content">
						<thead>
							<tr>
								<?php if (defined('WD_FM_PDF') && is_plugin_active(constant('WD_FM_PDF'))): ?> 
								<th class="table_small_col count_col sub-align">PDF</th>
								<?php endif; ?>
								<th class="table_small_col count_col sub-align">#</th>
								<th scope="col" id="cb" class="manage-column column-cb check-column table_small_col sub-align form_check"><input id="check_all" type="checkbox"></th>
								<th scope="col" id="submitid_fc" class="table_small_col sub-align submitid_fc <?php if ($order_by == "group_id") echo $oder_class; else echo $oder_class_default; ?>" <?php echo $style_id;?>>
									<a href="" class="sub_id" onclick="fm_set_input_value('order_by', 'group_id');
													   fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'group_id' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
													   fm_form_submit(event, 'admin_form')">
										<span>ID</span>
										<span class="sorting-indicator" style="margin-top: 8px;"></span>
									</a>
								</th>
								<th class="table_small_col sub-align">Edit</th>
								<th class="table_small_col sub-align">Delete</th>
								<th scope="col" id="submitdate_fc" class="table_large_col submitdate_fc <?php if ($order_by == "date") echo $oder_class; else echo $oder_class_default; ?>" <?php echo $style_date;?>>
									<a href="" onclick="fm_set_input_value('order_by', 'date');
										fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'date' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
										fm_form_submit(event, 'admin_form')">
										<span>Submit date</span>
										<span class="sorting-indicator"></span>
									</a>
								</th>
								<th scope="col" id="submitterip_fc" class="table_medium_col_uncenter submitterip_fc <?php if ($order_by == "ip")echo $oder_class; else echo $oder_class_default;  ?>" <?php echo $style_ip;?>>
									<a href="" onclick="fm_set_input_value('order_by', 'ip');
										fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'ip' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
										fm_form_submit(event, 'admin_form')">
										<span>Submitter's IP</span>
										<span class="sorting-indicator"></span>
									</a>
								</th>	
								<th scope="col" id="submitterusername_fc" class="table_medium_col_uncenter submitterusername_fc <?php if ($order_by == "display_name")echo $oder_class; else echo $oder_class_default;  ?>" <?php echo $style_username;?>>
									<a href="" onclick="fm_set_input_value('order_by', 'display_name');
										fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'display_name' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
										fm_form_submit(event, 'admin_form')">
										<span>Submitter's Username</span>
										<span class="sorting-indicator"></span>
									</a>
								</th>	
								<th scope="col" id="submitteremail_fc" class="table_medium_col_uncenter submitteremail_fc <?php if ($order_by == "user_email")echo $oder_class; else echo $oder_class_default;  ?>" <?php echo $style_useremail ;?>>
									<a href="" onclick="fm_set_input_value('order_by', 'user_email');
										fm_set_input_value('asc_or_desc', '<?php echo (($order_by == 'user_email' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>');
										fm_form_submit(event, 'admin_form')">
										<span>Submitter's Email Address</span>
										<span class="sorting-indicator"></span>
									</a>
								</th>	
								<?php
								for ($i = 0; $i < count($sorted_label_names); $i++) {
									$styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$i]); 
									$styleStr2 = $this->model->hide_or_not($lists['hide_label_list'] , '@payment_info@');		   
									$field_title = $this->model->get_type_address($sorted_label_types[$i], $sorted_label_names_original[$i]);
									if ($sorted_label_types[$i] == 'type_paypal_payment_status') {
										$ispaypal = TRUE;
										?>
										<th <?php echo $styleStr; ?> id="<?php echo $sorted_labels_id[$i] . '_fc'; ?>" class="table_large_col <?php echo $sorted_labels_id[$i] . '_fc'; if ($order_by == $sorted_labels_id[$i] . "_field") echo $oder_class . '"';else echo $oder_class_default . '"'; ?>">
											<a href="" onclick="fm_set_input_value('order_by', '<?php echo $sorted_labels_id[$i] . '_field'; ?>'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == $sorted_labels_id[$i] . '_field' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'admin_form')">	
												<span><?php echo $field_title; ?></span>
												<span class="sorting-indicator"></span>
											</a>
										</th>
										<th class="table_large_col payment_info_fc" <?php echo $styleStr2; ?>>Payment Info</th>
										<?php  
									}
									else {
										?>
										<th <?php echo $styleStr; ?> id="<?php  echo $sorted_labels_id[$i] . '_fc';?>" class="<?php echo ($sorted_label_types[$i] == 'type_mark_map' || $sorted_label_types[$i] == 'type_matrix') ? 'table_large_col ' : ''; echo $sorted_labels_id[$i] . '_fc'; if ($order_by == $sorted_labels_id[$i] . "_field") echo $oder_class . '"';else echo $oder_class_default . '"'; ?>">
											<a href="" onclick="fm_set_input_value('order_by', '<?php echo $sorted_labels_id[$i] . '_field'; ?>'); fm_set_input_value('asc_or_desc', '<?php echo (($order_by == $sorted_labels_id[$i] . '_field' && $asc_or_desc == 'asc') ? 'desc' : 'asc'); ?>'); fm_form_submit(event, 'admin_form')">
												<span><?php echo $field_title; ?></span>
												<span class="sorting-indicator"></span>
											</a>
										</th>
										<?php
									}
								}			
								?>		           
							</tr>
							<tr id="fields_filter" style="display: none;">
								<th></th>
								<th></th> 
								<th class="submitid_fc" <?php echo $style_id; ?> >
									<input type="text" name="id_search" id="id_search" value="<?php echo $lists['id_search'] ?>" onChange="this.form.submit();" style="width:30px"/>
								</th>
								<th></th>
								<th></th>
								<th width="150" class="submitdate_fc" <?php echo $style_date; ?>>
									<table align="center" style="margin:auto" class="simple_table">
										<tr class="simple_table">
											<td class="simple_table" style="text-align: left;">From:</td>
											<td style="text-align: center;" class="simple_table">
												<input class="inputbox" type="text" name="startdate" id="startdate" size="10" maxlength="10" value="<?php echo $lists['startdate']; ?>" />
											</td>
											<td style="text-align: center;" class="simple_table">
												<input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('startdate','%Y-%m-%d');" />
											</td>
										</tr>
										<tr class="simple_table">
											<td style="text-align: left;" class="simple_table">To:</td>
											<td style="text-align: center;" class="simple_table">
												<input class="inputbox" type="text" name="enddate" id="enddate" size="10" maxlength="10" value="<?php echo $lists['enddate']; ?>" />
											</td>
											<td style="text-align: center;" class="simple_table">
												<input type="reset" style="width: 22px; border-radius: 3px !important;" class="button" value="..." onclick="return showCalendar('enddate','%Y-%m-%d');" />
											</td>
										</tr>
									</table>
								</th>
								<th class="table_medium_col_uncenter submitterip_fc" <?php echo $style_ip; ?>>
									<input type="text" name="ip_search" id="ip_search" value="<?php echo $lists['ip_search']; ?>" onChange="this.form.submit();" />
								</th>
								<th class="table_medium_col_uncenter submitterusername_fc" <?php echo $style_username; ?>>
									<input type="text" name="username_search" id="username_search" value="<?php echo $lists['username_search']; ?>" onChange="this.form.submit();" />
								</th>
								<th class="table_medium_col_uncenter submitteremail_fc" <?php echo $style_useremail; ?>>
									<input type="text" name="useremail_search" id="useremail_search" value="<?php echo $lists['useremail_search']; ?>" onChange="this.form.submit();" />
								</th>
								<?php
								for ($i = 0; $i < count($sorted_label_names); $i++) {
									$styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$i]);
									if (!$ka_fielderov_search) {
										if ($lists[$form_id . '_' . $sorted_labels_id[$i] . '_search']) {
											$ka_fielderov_search = TRUE;
										}
									}	
									switch ($sorted_label_types[$i]) {
										case 'type_mark_map': ?>
											<th class="table_large_col <?php echo $sorted_labels_id[$i]; ?>_fc" <?php echo $styleStr; ?>></th>
											<?php
										break;
										case 'type_paypal_payment_status': ?>
											<th class="table_large_col <?php echo $sorted_labels_id[$i]; ?>_fc" <?php echo $styleStr; ?>>
												<select style="font-size: 11px; margin: 0; padding: 0; height: inherit;" name="<?php echo $form_id . '_' . $sorted_labels_id[$i]; ?>_search" id="<?php echo $form_id.'_'.$sorted_labels_id[$i]; ?>_search" onChange="this.form.submit();" value="<?php echo $lists[$form_id.'_'.$sorted_labels_id[$i].'_search']; ?>" >
													<option value="" ></option>
													<option value="canceled" >Canceled</option>
													<option value="cleared" >Cleared</option>
													<option value="cleared by payment review" >Cleared by payment review</option>
													<option value="completed" >Completed</option>
													<option value="denied" >Denied</option>
													<option value="failed" >Failed</option>
													<option value="held" >Held</option>
													<option value="in progress" >In progress</option>
													<option value="on hold" >On hold</option>
													<option value="paid" >Paid</option>
													<option value="partially refunded" >Partially refunded</option>
													<option value="pending verification" >Pending verification</option>
													<option value="placed" >Placed</option>
													<option value="processing" >Processing</option>
													<option value="refunded" >Refunded</option>
													<option value="refused" >Refused</option>
													<option value="removed" >Removed</option>
													<option value="returned" >Returned</option>
													<option value="reversed" >Reversed</option>
													<option value="temporary hold" >Temporary hold</option>
													<option value="unclaimed" >Unclaimed</option>
												</select>	
												<script> 
													var element = document.getElementById('<?php echo $form_id.'_'.$sorted_labels_id[$i]; ?>_search');
													element.value = '<?php echo $lists[$form_id.'_'.$sorted_labels_id[$i].'_search']; ?>';
												</script>
											</th>
											<th class="table_large_col  payment_info_fc" <?php echo $styleStr2; ?>></th>
											<?php				
										break;
										default: ?>
											<th class="<?php echo $sorted_labels_id[$i]; ?>_fc" <?php echo $styleStr; ?>>
												<input name="<?php echo $form_id .'_' . $sorted_labels_id[$i].'_search'; ?>" id="<?php echo $form_id .'_' . $sorted_labels_id[$i].'_search'; ?>" type="text" value="<?php echo $lists[$form_id.'_'.$sorted_labels_id[$i].'_search']; ?>"  onChange="this.form.submit();" >
											</th>
											<?php	
										break;			
									}
								}
								?>
							</tr>
						</thead>
						<?php
						$k = 0;
						for ($www = 0, $qqq = count($group_id_s); $www < $qqq; $www++) {
							$i = $group_id_s[$www];
							$alternate = (!isset($alternate) || $alternate == 'class="alternate"') ? '' : 'class="alternate"';
							$temp = $this->model->array_for_group_id($group_id_s[$www], $rows);
							$data = $temp[0];
							$userinfo=get_userdata($data->user_id_wd);
							$useremail=$userinfo ? $userinfo->user_email : "";
							$username=$userinfo ? $userinfo->display_name : "";
							?>
							<tr <?php echo $alternate; ?>>
								<?php if (defined('WD_FM_PDF') && is_plugin_active(constant('WD_FM_PDF'))): ?> 
								<td class="table_small_col pdf_col sub-align">
									<?php if($pdf_data && isset($pdf_data[$group_id_s[$www]])): ?> 
									<a href="<?php echo site_url().'/'.$pdf_data[$group_id_s[$www]]; ?>" style="display: block;" download><img src="<?php echo WD_FM_PDF_URL . '/images/pdf-icon.png'; ?>" /></a>
									<?php endif; ?>
								</td>
								<?php endif; ?>
								<td class="table_small_col count_col sub-align"><?php echo $www + 1; ?></td>
								<td class="check-column table_small_col sub-align" style="padding: 0;">
									<input type="checkbox" name="post[]" value="<?php echo $data->group_id; ?>">
								</td>   
								<td class="table_small_col sub-align submitid_fc" id="submitid_fc" <?php echo $style_id; ?>>
									<a href="" onclick="fm_set_input_value('task', 'edit');						   fm_set_input_value('current_id',<?php echo $data->group_id; ?>); fm_form_submit(event, 'admin_form');" >
										<?php echo $data->group_id; ?>
									</a>
								</td> 
								<td class="table_small_col sub-align">
									<a href="" onclick="fm_set_input_value('task', 'edit');						   fm_set_input_value('current_id',<?php echo $data->group_id; ?>); fm_form_submit(event, 'admin_form');">Edit
									</a>
								</td>
								<td class="table_small_col sub-align">
									<a href="" onclick="if (confirm('Do you want to delete selected item(s)?')) { fm_set_input_value('task', 'delete'); fm_set_input_value('current_id',<?php echo $data->group_id; ?>); fm_form_submit(event, 'admin_form'); } else { return false; }">Delete
									</a>
								</td>		 
								<td  class="table_large_col submitdate_fc sub-align" id="submitdate_fc" <?php echo $style_date; ?>>
									<a href="" onclick="fm_set_input_value('task', 'edit'); fm_set_input_value('current_id',<?php echo $data->group_id; ?>); fm_form_submit(event, 'admin_form');" ><?php echo $data->date ;?>
									</a>
								</td>
								<td class="table_medium_col_uncenter submitterip_fc sub-align" id="submitterip_fc" <?php echo $style_ip; ?>>
									<a class="thickbox-preview" href="<?php echo add_query_arg(array('action' => 'fromipinfoinpopup_fmc', 'data_ip' => $data->ip, 'width' => '400', 'height' => '300', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>" title="Show submitter information" <?php echo (!in_array($data->ip, $blocked_ips)) ? '' : 'style="color: #FF0000;"'; ?>><?php echo $data->ip; ?></a>
								</td>
								<td  class="table_large_col submitterusername_fc sub-align" id="submitterusername_fc" <?php echo $style_username; ?>>
									<?php   echo  $username; ?>
								</td>
								<td  class="table_large_col submitteremail_fc sub-align" id="submitteremail_fc" <?php echo $style_useremail; ?>>
									<?php  echo $useremail; ?>
								</td>
								<?php
								for ($h = 0; $h < $m; $h++) {
									$not_label = TRUE;
									for ($g = 0; $g < count($temp); $g++) {
										$styleStr = $this->model->hide_or_not($lists['hide_label_list'], $sorted_labels_id[$h]);
										if ($temp[$g]->element_label == $sorted_labels_id[$h]) {
											if (strpos($temp[$g]->element_value, "***map***")) {
												$map_params = explode('***map***', $temp[$g]->element_value);
												?>
												<td class="table_large_col <?php echo $sorted_labels_id[$h]; ?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
													<a class="thickbox-preview" href="<?php echo add_query_arg(array('action' => 'frommapeditinpopup_fmc', 'long' => $map_params[0], 'lat' => $map_params[1], 'width' => '620', 'height' => '550', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>" title="Show on Map">Show on Map</a>
												</td>
												<?php 
											}
											elseif (strpos($temp[$g]->element_value, "*@@url@@*")) {
												?>
												<td class="<?php echo $sorted_labels_id[$h]; ?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
													<?php
													$new_files = explode("*@@url@@*", $temp[$g]->element_value);
													foreach ($new_files as $new_file) {
														if ($new_file) {
															$new_filename = explode('/', $new_file);
															$new_filename = $new_filename[count($new_filename) - 1];
															?>
															<a target="_blank" class="fm_fancybox" rel="group_<?php echo $www; ?>" href="<?php echo $new_file; ?>"><?php echo $new_filename; ?></a><br />
															<?php
														}
													}
													?>
												</td>
												<?php
											}
											elseif (strpos($temp[$g]->element_value, "***star_rating***")) {
												$view_star_rating_array = $this->model->view_for_star_rating($temp[$g]->element_value, $temp[$g]->element_label);
												$stars = $view_star_rating_array[0];
												?>
												<td align="center" class="<?php echo $sorted_labels_id[$h];?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>><?php echo $stars; ?></td>
												<?php  
											}
											elseif (strpos($temp[$g]->element_value, "***matrix***")) {
												?>   
												<td class="table_large_col <?php echo $sorted_labels_id[$h];?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
													<a class="thickbox-preview" href="<?php echo add_query_arg(array('action' => 'show_matrix', 'matrix_params' => $temp[$g]->element_value, 'width' => '620', 'height' => '550', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>" title="Show Matrix">Show Matrix</a>
												</td>
												<?php
											}
											elseif (strpos($temp[$g]->element_value, "@@@") !== FALSE || $temp[$g]->element_value == "@@@" || $temp[$g]->element_value == "@@@@@@@@@") {
												?>
												<td class="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
													<p><?php echo str_replace("@@@", " ", $temp[$g]->element_value); ?></p>
												</td>
												<?php
											}
											elseif (strpos($temp[$g]->element_value, "***grading***")) {
												$view_grading_array = $this->model->view_for_grading($temp[$g]->element_value);
												$items = $view_grading_array[0];
												?>
												<td class="<?php echo $sorted_labels_id[$h];?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
													<p><?php echo $items; ?></p>
												</td>
												<?php
											}
											else {
												if (strpos($temp[$g]->element_value, "***quantity***")) {
													$temp[$g]->element_value = str_replace("***quantity***", " ", $temp[$g]->element_value);
												}
												if (strpos($temp[$g]->element_value, "***property***")) {
													$temp[$g]->element_value = str_replace("***property***", " ", $temp[$g]->element_value);
												}

												if($sorted_label_types[$h]=="type_submitter_mail"){	
													$query = $wpdb->prepare('SELECT id FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id ="%d" AND group_id="%d" AND element_value="verified**%d"', $form_id, $i, $sorted_labels_id[$h]);
													$isverified = $wpdb->get_var($query);
								
													if($isverified) { ?>
														<td class="<?php echo $sorted_labels_id[$h];?>_fc" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
															<p><?php echo $temp[$g]->element_value; ?> <span style="color:#2DA068;">( Verified <img src="<?php echo WD_FMC_URL . '/images/verified.png'; ?>" /> )</span></p>
														</td>
													<?php }	
													else {?>
														<td class="<?php echo $sorted_labels_id[$h];?>_fc" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
															<p><?php echo $temp[$g]->element_value; ?></p>
														</td>	
													<?php }	
												}	
												else{
													?>
													<td class="<?php echo $sorted_labels_id[$h];?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>>
														<p><?php echo str_replace("***br***", '<br>', stripslashes($temp[$g]->element_value)) ; ?></p>
													</td>
													<?php   
												}
											}	
											$not_label = FALSE;
										}
									}
									if ($not_label) {
										?>
										<td class="<?php echo $sorted_labels_id[$h];?>_fc sub-align" id="<?php echo $sorted_labels_id[$h]; ?>_fc" <?php echo $styleStr; ?>><p>&nbsp;</p></td>
										<?php
									}
								}
								if ($ispaypal) {
									$styleStr = $this->model->hide_or_not($lists['hide_label_list'], '@payment_info@');
									?>
									<td class="table_large_col payment_info_fc sub-align" id="payment_info_fc" <?php echo $styleStr; ?>>
										<a class="thickbox-preview" href="<?php echo add_query_arg(array('action' => 'paypal_info', 'id' => $i, 'width' => '600', 'height' => '500', 'TB_iframe' => '1'), admin_url('admin-ajax.php')); ?>">
											<img src="<?php echo WD_FMC_URL . '/images/info.png'; ?>" />
										</a>
									</td>
									<?php
								}
								?>
							</tr>
							<?php
							$k = 1 - $k;
						}
						?>
					</table>
				</div>	 
				<?php
				if ($sorted_label_types) {
					foreach ($sorted_label_types as $key => $sorted_label_type) {
						if ($this->model->check_radio_type($sorted_label_type)) {
							$is_stats = true;
							break;
						}
					}
					if ($is_stats) {
						$ajax_nonce = wp_create_nonce( "nonce_fmc_ajax" );
						?>
						<br/>
						<div class="fm-statistics">
							<h1>Statistics</h1>		
							<table class="stats">
								<tr>
									<td>
										<label for="sorted_label_key">Select a Field:</label>
									</td>
									<td>
										<select id="sorted_label_key">
											<option value="">Select a Field</option>
											<?php 
											foreach ($sorted_label_types as $key => $sorted_label_type) {
												if ($sorted_label_type=="type_checkbox" || $sorted_label_type=="type_radio" || $sorted_label_type=="type_own_select" || $sorted_label_type=="type_country" || $sorted_label_type=="type_paypal_select" || $sorted_label_type=="type_paypal_radio" || $sorted_label_type=="type_paypal_checkbox" || $sorted_label_type=="type_paypal_shipping") {				  
													?>
													<option value="<?php echo $key; ?>"><?php echo $sorted_label_names_original[$key]; ?></option>
													<?php
												}
											}
											?>
										</select>
									</td>
									<td></td>
								</tr>
								<tr>
									<td>
										<label>Select a Date:</label>
									</td>
									<td>
										From: <input class="inputbox"  type="text" name="startstats" id="startstats" size="9" maxlength="9" />
										  <input type="reset" class="button" style="width: 22px;"  value="..." name="startstats_but" id="startstats_but" onclick="return showCalendar('startstats','%Y-%m-%d');" /> 
											 
										To: <input class="inputbox" type="text" name="endstats" id="endstats" size="9" maxlength="9" />
										<input type="reset" class="button" style="width: 22px;"  value="..." name="endstats_but" id="endstats_but" onclick="return showCalendar('endstats','%Y-%m-%d');" />
									</td>
									<td>
										<button onclick="show_stats(); return false;">Show</button>
									</td>
								</tr>
							</table>
							
							<div id="div_stats"></div>	
						</div>
						<script>
						function show_stats() { 
							jQuery('#div_stats').html('<div class="fm-loading-container"><div class="fm-loading-content"></div></div>');
							if(jQuery('#sorted_label_key').val()!="") {	 	  
								jQuery('#div_stats').load('<?php echo add_query_arg(array('action' => 'get_stats_fmc', 'page' => 'submissions_fmc'), admin_url('admin-ajax.php')); ?>', { 
									'task': 'show_stats',
									'form_id' : '<?php echo $form_id; ?>',
									'sorted_label_key' : jQuery('#sorted_label_key').val(),
									'startdate' : jQuery('#startstats').val(), 
									'enddate' : jQuery('#endstats').val(),
									'nonce_fmc_ajax': '<?php echo $ajax_nonce; ?>'
								});
							}		
							else {
								jQuery('#div_stats').html("<div style='padding:10px 5px; color:red; font-size:14px;'>Please select the field!</div>");
							}	
							jQuery("#div_stats").removeClass("fm_loading");
						}
						</script>
						<?php	
					}
				}
				?>
			</div>	
		</form>	
		<script> 
		function fm_scroll(element) {
			var scrollbar= document.createElement('div');
			scrollbar.appendChild(document.createElement('div'));
			scrollbar.style.overflow= 'auto';
			scrollbar.style.overflowY= 'hidden';
			scrollbar.firstChild.style.width= element.scrollWidth+'px';
			scrollbar.firstChild.style.paddingTop= '1px';
			scrollbar.firstChild.appendChild(document.createTextNode('\xA0'));
			scrollbar.onscroll= function() {
				element.scrollLeft= scrollbar.scrollLeft;
			};
			element.onscroll= function() {
				scrollbar.scrollLeft= element.scrollLeft;
			};
			element.parentNode.insertBefore(scrollbar, element);
		}
		jQuery(window).load(function() {
			fm_popup();
			fm_scroll(document.getElementById('fm-scroll'));
			if (typeof jQuery().fancybox !== 'undefined' && jQuery.isFunction(jQuery().fancybox)) {
				jQuery(".fm_fancybox").fancybox({
					'maxWidth ' : 600,
					'maxHeight' : 500
				});
			}
		});
		<?php if ($ka_fielderov_search) { ?> 
			document.getElementById('fields_filter').style.display = '';
        <?php } ?>
		</script>
		<?php
	}

	public function show_stats($form_id) {
		$key = (isset($_POST['sorted_label_key']) ? esc_html(stripslashes($_POST['sorted_label_key'])) : ''); 
		$labels_parameters = $this->model->get_labels_parameters($form_id);
		$where_choices = $labels_parameters[7];
		$sorted_label_names_original = $labels_parameters[4];
		$sorted_labels_id = $labels_parameters[0];	 
		if(count($sorted_labels_id)!=0 && $key < count($sorted_labels_id)  ) { 
			$choices_params = $this->model->statistic_for_radio($where_choices, $sorted_labels_id[$key]);
			$sorted_label_name_original = $sorted_label_names_original[$key];
			$choices_count = $choices_params[0];
			$choices_labels = $choices_params[1];
			$unanswered = $choices_params[2];
			$all = $choices_params[3];
			$colors = $choices_params[4];	  
			$choices_colors = $choices_params[5];	  
		}
		else {
			$choices_labels = array();
			$sorted_label_name_original = '';
			$unanswered = NULL;
			$all = 0;
		}
		?>
		<br/>
		<br/>
		<div class="field-label"><?php echo stripslashes($sorted_label_name_original); ?></div>
		<table class="adminlist">
			<thead>
				<tr>
					<th width="20%">Choices</th>
					<th>Percentage</th>
					<th width="10%">Count</th>
				</tr>
			</thead>
			<?php
			$k=0;
			foreach ($choices_labels as $key => $choices_label) {
				if (strpos($choices_label, "***quantity***")) {
					$choices_label = str_replace("***quantity***", " ", $choices_label);
				}
				if (strpos($choices_label, "***property***")) {
					$choices_label = str_replace("***property***", " ", $choices_label);
				}
				?>
				<tr>
					<td class="label<?php echo $k; ?>"><?php echo str_replace("***br***",'<br>', $choices_label)?></td>
					<td>
						<div class="bordered" style="width:<?php echo ($choices_count[$key]/($all-$unanswered))*100; ?>%; height:16px; background-color:<?php echo $colors[$key % 2]; ?>; float: left;">
						</div>
						<div <?php echo ($choices_count[$key]/($all-$unanswered)!=1 ? 'class="bordered'.$k.'"' : "") ?> style="width:<?php echo 100-($choices_count[$key]/($all-$unanswered))*100; ?>%; height:16px; background-color:#F2F0F1; float: left;">
						</div>
					</td>
					<td>
						<div>
							<div style="width: 0; height: 0; border-top: 8px solid transparent;border-bottom: 8px solid transparent; border-right:8px solid <?php echo $choices_colors[$key % 2]; ?>; float:left;">
							</div>
							<div style="background-color:<?php echo $choices_colors[$key % 2]; ?>; height:16px; width:16px; text-align: center; margin-left:8px; color: #fff;">
							<?php echo $choices_count[$key]?>
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="3">
					</td>
				</tr>
				<?php
				$k = 1 - $k;
			}
			if($unanswered){
				?>
				<tr>
					<td colspan="2" style="text-align:right; color: #000;">Unanswered</th>
					<td><strong style="margin-left:10px;"><?php echo $unanswered;?></strong></th>
				</tr>
				<?php	
			}
			?>
			<tr>
				<td colspan="2" style="text-align:right; color: #000;"><strong>Total</strong></th>
				<td><strong style="margin-left:10px;"><?php echo $all;?></strong></th>
			</tr>
		</table>
		<?php
		die();
	}

  public function edit($id) {
    $current_id = ((isset($id)) ? $id : 0);
    $params = $this->model->get_data_of_group_id($current_id);
    $rows = $params[0];
    $labels_id = $params[1];
    $labels_name = $params[2];
    $labels_type = $params[3];
    $ispaypal = $params[4];
	$userinfo = get_userdata($rows[0]->user_id_wd);
	$username = $userinfo ? $userinfo->display_name : "";
	$useremail = $userinfo ? $userinfo->user_email : "";
	
    ?>
    <form action="admin.php?page=submissions_fmc" method="post" id="adminForm" name="adminForm">
      <?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
      <table width="99%">
        <tbody>
          <tr>
            <td width="100%"><h2>Edit Submission</h2></td>
            <td align="right">
              <input type="button" onclick="fm_set_input_value('task', 'save');						  
                                            fm_set_input_value('current_id', <?php echo $current_id; ?>);
                                            fm_form_submit(event, 'adminForm');" value="Save" class="button-secondary action">
            </td>
            <td align="right">
              <input type="button" onclick="fm_set_input_value('task', 'apply');						  
                                            fm_set_input_value('current_id', <?php echo $current_id ;?>);
                                            fm_form_submit(event, 'adminForm');" value="Apply" class="button-secondary action">
            </td>
            <td align="right">
              <input type="button" onclick="fm_set_input_value('task', '');fm_form_submit(event, 'adminForm');" value="Cancel" class="button-secondary action">
            </td>
          </tr>
        </tbody>
      </table>
      <table class="admintable">
        <tr>
          <td class="key"><label for="ID">ID: </label></td>
          <td><?php echo $rows[0]->group_id; ?></td>
        </tr>
        <tr>
          <td class="key"><label for="Date">Date: </label></td>
          <td><?php echo $rows[0]->date; ?></td>
        </tr>
        <tr>
          <td class="key"><label for="IP">IP: </label></td>
          <td><?php echo $rows[0]->ip; ?></td>
        </tr>
		
		
		<tr>
          <td class="key"><label for="Submitter's Username">Submitter's Username: </label></td>
          <td><?php echo $username; ?></td>
        </tr>
		<tr>
          <td class="key"><label for="Submitter's Email Address">Submitter's Email Address: </label></td>
          <td><?php echo $useremail; ?></td>
        </tr>
        <?php
        foreach ($labels_id as $key => $label_id) {
          if ($this->model->check_type_for_edit_function($labels_type[$key])) {
            $element_value = $this->model->check_for_submited_label($rows, $label_id);
            if ($element_value == "continue") {
              continue;
            }
            switch ($labels_type[$key]) {
              case 'type_checkbox':
                $choices = explode('***br***', $element_value);
                $choices = array_slice($choices, 0, count($choices) - 1);
                ?>
				<tr>
          <td class="key" rowspan="<?php echo count($choices); ?>">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
                <?php
                foreach ($choices as $choice_key => $choice) {
                  ?>
				  <td>
            <input type="text" name="submission_<?php echo $label_id.'_'.$choice_key; ?>" id="submission_<?php echo $label_id.'_'.$choice_key; ?>" value="<?php echo $choice; ?>" size="80" />
				  </td>
				</tr>
                  <?php
                }
                break;
              case 'type_paypal_payment_status':
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <select name="submission_0" id="submission_0" >
              <option value=""></option>
              <option value="Canceled" >Canceled</option>
              <option value="Cleared" >Cleared</option>
              <option value="Cleared by payment review" >Cleared by payment review</option>
              <option value="Completed" >Completed</option>
              <option value="Denied" >Denied</option>
              <option value="Failed" >Failed</option>
              <option value="Held" >Held</option>
              <option value="In progress" >In progress</option>
              <option value="On hold" >On hold</option>
              <option value="Paid" >Paid</option>
              <option value="Partially refunded" >Partially refunded</option>
              <option value="Pending verification" >Pending verification</option>
              <option value="Placed" >Placed</option>
              <option value="Processing" >Processing</option>
              <option value="Refunded" >Refunded</option>
              <option value="Refused" >Refused</option>
              <option value="Removed" >Removed</option>
              <option value="Returned" >Returned</option>
              <option value="Reversed" >Reversed</option>
              <option value="Temporary hold" >Temporary hold</option>
              <option value="Unclaimed" >Unclaimed</option>
            </select>	
            <script> 
              var element = document.getElementById("submission_0");
              element.value = "<?php echo $element_value; ?>";
            </script>
			    </td>
				</tr>
                <?php
                break;
              case 'type_star_rating':
                $star_rating_array = $this->model->images_for_star_rating($element_value, $label_id);
                $edit_stars = $star_rating_array[0];
                $stars_value = $star_rating_array[1];
                ?>
        <tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <input type="hidden" id="<?php echo $label_id; ?>_star_amountform_id_temp" name="<?php echo $label_id; ?>_star_amountform_id_temp" value="<?php echo $stars_value[0]; ?>">
            <input type="hidden" name="<?php echo $label_id; ?>_star_colorform_id_temp" id="<?php echo $label_id; ?>_star_colorform_id_temp" value="<?php echo $stars_value[2]; ?>">
            <input type="hidden" id="<?php echo $label_id; ?>_selected_star_amountform_id_temp" name="<?php echo $label_id; ?>_selected_star_amountform_id_temp" value="<?php echo $stars_value[1]; ?>">
            <?php echo $edit_stars; ?>
            <input type="hidden" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo $element_value; ?>" size="80" />
          </td>
        </tr>
                <?php
                break;
              case "type_scale_rating":
                $scale_rating_array = $this->model->params_for_scale_rating($element_value, $label_id);
                $scale = $scale_rating_array[0];
                $scale_radio = $scale_rating_array[1];
                $checked = $scale_rating_array[2];
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <input type="hidden" id="<?php echo $label_id; ?>_scale_checkedform_id_temp" name="<?php echo $label_id; ?>_scale_checkedform_id_temp" value="<?php echo $scale_radio[1]; ?>">
            <?php echo $scale; ?>
            <input type="hidden" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo $element_value; ?>" size="80" />
          </td>
				</tr>
                <?php
                break;
              case 'type_range':
                $range = $this->model->params_for_type_range($element_value, $label_id);
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <?php echo $range; ?>
            <input type="hidden" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo $element_value; ?>" size="80" />
          </td>
				</tr>
                <?php
                break;
              case 'type_spinner':
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <input type="text" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo str_replace("*@@url@@*", '', $element_value); ?>" size="20" />
          </td>
        </tr>
                <?php
                break;
              case 'type_grading':
                $type_grading_array = $this->model->params_for_type_grading($element_value, $label_id);
                $garding = $type_grading_array[0];
                $garding_value = $type_grading_array[1];
                $sum = $type_grading_array[2];
                $items_count = $type_grading_array[3];
                $element_value1 = $type_grading_array[4];
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <?php echo $garding; ?>
            <span id="<?php echo $label_id; ?>_grading_sumform_id_temp"><?php echo $sum; ?></span>/<span id="<?php echo $label_id; ?>_grading_totalform_id_temp"><?php echo $garding_value[$items_count]; ?></span><span id="<?php echo $label_id; ?>_text_elementform_id_temp"></span>
            <input type="hidden"  id="<?php echo $label_id; ?>_element_valueform_id_temp" name="<?php echo $label_id; ?>_element_valueform_id_temp" value="<?php echo $element_value1; ?>" />
            <input type="hidden"  id="<?php echo $label_id; ?>_grading_totalform_id_temp" name="<?php echo $label_id; ?>_grading_totalform_id_temp" value="<?php echo $garding_value[$items_count]; ?>" />
            <input type="hidden" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo $element_value; ?>" size="80" />
          </td>
				</tr>
                <?php
                break;
              case 'type_matrix':
                $type_matrix_array = $this->model->params_for_type_matrix($element_value, $label_id);
                $matrix = $type_matrix_array[0];
                $new_filename = $type_matrix_array[1];
                ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <input type="hidden"  id="<?php echo $label_id; ?>_matrixform_id_temp" name="<?php echo $label_id; ?>_matrixform_id_temp" value="<?php echo $new_filename; ?>">
            <?php echo $matrix; ?>
            <input type="hidden" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo $element_value; ?>" size="80" />
          </td>
				</tr>
                <?php
                break;
              default: 
              ?>
				<tr>
          <td class="key">
            <label for="title"><?php echo $labels_name[$key]; ?></label>
          </td>
          <td>
            <input type="text" name="submission_<?php echo $label_id; ?>" id="submission_<?php echo $label_id; ?>" value="<?php echo str_replace("*@@url@@*", '', $element_value); ?>" size="80" />
          </td>
        </tr>
              <?php
                break;
            }
          }
        }
        ?>
      </table>
      <input type="hidden" name="option" value="com_formmaker"/>
      <input type="hidden" id="current_id" name="current_id" value="<?php echo $rows[0]->group_id; ?>" />
      <input type="hidden" name="form_id" value="<?php echo $rows[0]->form_id; ?>" />
      <input type="hidden" name="date" value="<?php echo $rows[0]->date; ?>" />
      <input type="hidden" name="ip" value="<?php echo $rows[0]->ip; ?>" />
      <input type="hidden" id="task" name="task" value="" />
      <input type="hidden" value="<?php echo WD_FMC_URL; ?>" id="form_plugins_url" />
      <script>
        plugin_url = document.getElementById('form_plugins_url').value;
      </script>
    </form>
	  <?php
  }

  public function new_edit($id) {
    $current_id = ((isset($id)) ? $id : 0);
    $params = $this->model->get_data_of_group_id($current_id);
    $rows = $params[0]; 
    $labels_id = $params[1]; 
    $labels_name = $params[2]; 
    $labels_type = $params[3];
    $ispaypal = $params[4];
    $form = $params[5];
    $form_theme = $params[6];
    $userinfo = get_userdata($rows[0]->user_id_wd);
    $username = $userinfo ? $userinfo->display_name : "";
    $useremail = $userinfo ? $userinfo->user_email : "";
    ?>
	<div class="fm-user-manual">
		This section allows you to edit form submissions.
		<a style="color: blue; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-form-maker-guide-6.html">Read More in User Manual</a>
	</div>
	<div class="fm-upgrade-pro">
		<a target="_blank" href="https://web-dorado.com/files/fromContactForm.php">
			<div class="fm-upgrade-img">
				UPGRADE TO PRO VERSION 
				<span></span>
			</div>
		</a>
	</div>
	<div class="fm-clear"></div>
    <form action="admin.php?page=submissions_fmc"  method="post" id="formform_id_temp" name="formform_id_temp">
		<?php wp_nonce_field('nonce_fmc', 'nonce_fmc'); ?>
		<div class="fm-page-header">
			<div class="fm-page-title">Edit Submission</div>
			<div class="fm-page-actions">
				<button class="fm-button save-button small" onclick="pressbutton(); fm_set_input_value('task', 'save');	 fm_set_input_value('current_id', <?php echo $current_id ;?>); fm_form_submit(event, 'formform_id_temp');">
					<span></span>
					Save
				</button>
				<button class="fm-button apply-button small" onclick="pressbutton(); fm_set_input_value('task', 'apply');	 fm_set_input_value('current_id', <?php echo $current_id ;?>); fm_form_submit(event, 'formform_id_temp');">
					<span></span>
					Apply
				</button>
				<button class="fm-button cancel-button small" onclick="fm_set_input_value('task', '');fm_form_submit(event, 'formform_id_temp');">
					<span></span>
					Cancel
				</button>
			</div>
			<div class="fm-clear"></div>
		</div>
		<div class="fm-submissins-edit">
		<table>
			<tr>
				<td class="fm-key"><label for="ID">ID: </label></td>
				<td><?php echo $rows[0]->group_id; ?></td>
			</tr>	
			<tr>
				<td class="fm-key"><label for="Date">Date: </label></td>
				<td><?php echo $rows[0]->date; ?></td>
			</tr>
			<tr>
				<td class="fm-key"><label for="IP">IP: </label></td>
				<td><?php echo $rows[0]->ip; ?></td>
			</tr>
			<tr>
				<td class="fm-key"><label for="Submitter's Username">Submitter's Username: </label></td>
				<td><?php echo $username; ?></td>
			</tr>
			<tr>
				<td class="fm-key"><label for="Submitter's Email Address">Submitter's Email Address: </label></td>
				<td><?php echo $useremail; ?></td>
			</tr>
		</table>
		<?php
		$css_rep1 = array("[SITE_ROOT]");
		$css_rep2 = array(WD_FMC_URL);
		$order = array("\r\n", "\n", "\r");
		$form_theme = str_replace($order, '', $form_theme);
		$form_theme = str_replace($css_rep1, $css_rep2, $form_theme);
		$form_theme = "#form" . $form->id . ' ' . $form_theme;
		?>
		<style>
        <?php
        echo $form_theme;
        ?>
        .wdform-page-and-images{
          width: 50%;
        }
        .wdform-page-and-images div {
          background-color: rgba(0, 0, 0, 0);
        }
      </style>
      <?php	
      $form_currency = '$';
      $check_js = '';
      $onload_js = '';
      $onsubmit_js = '';
      $currency_code = array('USD', 'EUR', 'GBP', 'JPY', 'CAD', 'MXN', 'HKD', 'HUF', 'NOK', 'NZD', 'SGD', 'SEK', 'PLN', 'AUD', 'DKK', 'CHF', 'CZK', 'ILS', 'BRL', 'TWD', 'MYR', 'PHP', 'THB');
      $currency_sign = array('$'  , '€'  , '£'  , '¥'  , 'C$', 'Mex$', 'HK$', 'Ft' , 'kr' , 'NZ$', 'S$' , 'kr' , 'zl' , 'A$' , 'kr' , 'CHF' , 'Kc', '?'  , 'R$' , 'NT$', 'RM' , '?'  , '?'  );
      $is_type	= array();
      $id1s = array();
      $types = array();
      $labels = array();
      $paramss = array();
      $fields = explode('*:*new_field*:*', $form->form_fields);
      $fields = array_slice($fields, 0, count($fields) - 1);   
      foreach ($fields as $field) {
        $temp = explode('*:*id*:*',$field);
        array_push($id1s, $temp[0]);
        $temp = explode('*:*type*:*', $temp[1]);
        array_push($types, $temp[0]);
        $temp = explode('*:*w_field_label*:*', $temp[1]);
        array_push($labels, $temp[0]);
        array_push($paramss, $temp[1]);
      }
      $form = $form->form_front;
      $form_id = 'form_id_temp';
      $start = 0;
      foreach ($id1s as $id1s_key => $id1) {
        $label = $labels[$id1s_key];
        $type = $types[$id1s_key];
        $params = $paramss[$id1s_key];
        if ($type != 'type_address') {
          foreach ($rows as $row) {
            if ($row->element_label == $id1) {		
              $element_value =	$row->element_value;
              break;
            }
            else {
              $element_value =	'';
            }
          }
        }
        else {
          for ($i = 0; $i < 6; $i++) {
            $address_value = '';
            foreach ($rows as $row) {
              if ($row->element_label == (string)((int) $id1 + $i)) {
                $address_value = $row->element_value;
              }
            }
            $elements_of_address[$i] = $address_value;
          }
        }
        if (strpos($form, '%' . $id1 . ' - ' . $label . '%')) {
          $rep = '';
          $param = array();
          $param['attributes'] = '';
          $is_type[$type] = TRUE;
          switch ($type) {
            case 'type_section_break':
            case 'type_editor':
            case 'type_file_upload':
            case 'type_captcha':		
            case 'type_recaptcha':
            case 'type_mark_map':	
            case 'type_map':
            case 'type_submit_reset':
            case 'type_button':
            case 'type_paypal_total':
              break;
            
            case 'type_text': {
              $params_names = array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_required','w_unique');
              $temp = $params;
              foreach ($params_names as $params_name ) {
                $temp = explode('*:*'.$params_name.'*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {	
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);   
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' '.$attr;
                }
              }
              $wdformfieldsize = ($param['w_field_label_pos'] == "left" ? $param['w_field_label_size']+$param['w_size'] : max($param['w_field_label_size'],$param['w_size']));
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "float: left;" : "display:block;");
              $rep ='<div type="type_text" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              $rep.='</div><div class="wdform-element-section" style="width: '.$param['w_size'].'px;"  ><input type="text" class="" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$element_value.'" style="width: 100%;" '.$param['attributes'].'></div></div>';
              break;
            }

            case 'type_number': {
              $params_names = array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_required','w_unique','w_class');
              $temp = $params;
              foreach ($params_names as $params_name ) {	
                $temp = explode('*:*'.$params_name.'*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }				
              
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? $param['w_field_label_size']+$param['w_size'] : max($param['w_field_label_size'],$param['w_size']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
              $rep ='<div type="type_number" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section"  class="'.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size'].'px;"><input type="text" class="" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$element_value.'"  style="width: 100%;" '.$param['attributes'].'></div></div>';
              
              break;
            }

            case 'type_password': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_required','w_unique','w_class');
              $temp=$params;

              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
                        
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
          
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? $param['w_field_label_size']+$param['w_size'] : max($param['w_field_label_size'],$param['w_size']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                

              $rep ='<div type="type_password" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section"  class="'.$param['w_class'].'" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size'].'px;"><input type="password" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$element_value.'" style="width: 100%;" '.$param['attributes'].'></div></div>';
              
              
              break;
            }

            case 'type_textarea': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size_w','w_size_h','w_first_val','w_title','w_required','w_unique','w_class');
              $temp=$params;

              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              
              
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
            
            
                
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? $param['w_field_label_size']+$param['w_size_w'] : max($param['w_field_label_size'],$param['w_size_w']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
            
            
              $rep ='<div type="type_textarea" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size_w'].'px"><textarea class="" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" title="'.$param['w_title'].'"  style="width: 100%; height: '.$param['w_size_h'].'px;" '.$param['attributes'].'>'.$element_value.'</textarea></div></div>';

              

              break;
            }

            case 'type_wdeditor': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size_w','w_size_h','w_title','w_required','w_class');
              $temp=$params;
            
              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
                      
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? $param['w_field_label_size']+$param['w_size_w']+10 : max($param['w_field_label_size'],$param['w_size_w']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                                    
              $rep ='<div type="type_wdeditor" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
            
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size_w'].'px">';
              
              if(user_can_richedit()) {
                ob_start();
                wp_editor($element_value, 'wdform_'.$id1.'_wd_editor'.$form_id, array('teeny' => FALSE, 'media_buttons' => FALSE, 'textarea_rows' => 5));
                $wd_editor = ob_get_clean();
              }
              else {
                $wd_editor='
                <textarea  class="'.$param['w_class'].'" name="wdform_'.$id1.'_wd_editor'.$form_id.'" id="wdform_'.$id1.'_wd_editor'.$form_id.'" style="width: '.$param['w_size_w'].'px; height: '.$param['w_size_h'].'px; " class="mce_editable" aria-hidden="true">'.$element_value.'</textarea>';
              }	
              
              $rep.= $wd_editor.'</div></div>';
      
              break;
            }

            case 'type_phone': {
            
              if($element_value=='')
                $element_value = ' ';
                
                $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_mini_labels','w_required','w_unique', 'w_class');
                $temp=$params;

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                } 
                
                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
                
                $element_value = explode(' ',$element_value);
              
                $wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']+65) : max($param['w_field_label_size'],($param['w_size']+65)));	
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");		
                
                $w_mini_labels = explode('***',$param['w_mini_labels']);
            
                $rep ='<div type="type_phone" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label" >'.$label.'</span>';
                
                $rep.='
                </div>
                <div class="wdform-element-section '.$param['w_class'].'" style="width: '.($param['w_size']+65).'px;">
                  <div style="display: table-cell;vertical-align: middle;">
                    <div><input type="text" class="" id="wdform_'.$id1.'_element_first'.$form_id.'" name="wdform_'.$id1.'_element_first'.$form_id.'" value="'.$element_value[0].'" style="width: 50px;" '.$param['attributes'].'></div>
                    <div><label class="mini_label">'.$w_mini_labels[0].'</label></div>
                  </div>
                  <div style="display: table-cell;vertical-align: middle;">
                    <div class="wdform_line" style="margin: 0px 4px 10px 4px; padding: 0px;">-</div>
                  </div>
                  <div style="display: table-cell;vertical-align: middle; width:100%;">
                    <div><input type="text" class="" id="wdform_'.$id1.'_element_last'.$form_id.'" name="wdform_'.$id1.'_element_last'.$form_id.'" value="'.$element_value[1].'" style="width: 100%;" '.$param['attributes'].'></div>
                    <div><label class="mini_label">'.$w_mini_labels[1].'</label></div>
                  </div>
                </div>
                </div>';

              break;
            }

            case 'type_name': {
            
              if($element_value =='')
                $element_value = '@@@';
              
               $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_first_val', 'w_title', 'w_mini_labels', 'w_size', 'w_name_format', 'w_required', 'w_unique', 'w_class');
               $temp = $params;
			   if(strpos($temp, 'w_name_fields') > -1)
				$params_names = array('w_field_label_size', 'w_field_label_pos', 'w_first_val', 'w_title', 'w_mini_labels', 'w_size', 'w_name_format', 'w_required', 'w_unique', 'w_class', 'w_name_fields');

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }
                
                
                if($temp) {	
                  $temp	= explode('*:*w_attr_name*:*',$temp);
                  $attrs = array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
                
                $w_mini_labels = explode('***',$param['w_mini_labels']);
			    $param['w_name_fields'] = isset($param['w_name_fields']) ? $param['w_name_fields'] : ($param['w_name_format'] == 'normal' ? 'no***no' : 'yes***yes');
			    $w_name_fields = explode('***', $param['w_name_fields']);
                $element_value = explode('@@@', $element_value);
				
				if($w_name_fields[0]== 'no' && $w_name_fields[1]== 'no' ) {
					$w_name_format = '
						<div style="display: table-cell; width:50%">
						  <div><input type="text" class="" id="wdform_'.$id1.'_element_first'.$form_id.'" name="wdform_'.$id1.'_element_first'.$form_id.'" value="'.(count($element_value)==2 ? $element_value[0] : $element_value[1]).'" style="width: 100%;"'.$param['attributes'].'></div>
						  <div><label class="mini_label">'.$w_mini_labels[1].'</label></div>
						</div>
						<div style="display:table-cell;"><div style="margin: 0px 8px; padding: 0px;"></div></div>
						<div  style="display: table-cell; width:50%">
						  <div><input type="text" class="" id="wdform_'.$id1.'_element_last'.$form_id.'" name="wdform_'.$id1.'_element_last'.$form_id.'" value="'.(count($element_value)==2 ? $element_value[1] : $element_value[2]).'" style="width: 100%;" '.$param['attributes'].'></div>
						  <div><label class="mini_label">'.$w_mini_labels[2].'</label></div>
						</div>
						';
					$w_size=2*$param['w_size'];
				 }
				else {
					$first_last_size = $w_name_fields[0] == 'yes' && $w_name_fields[1] == 'no' ? 45 : 30;
					$w_name_format = '
						<div style="display: table-cell; width:30%">
						  <div><input type="text" class="" id="wdform_'.$id1.'_element_first'.$form_id.'" name="wdform_'.$id1.'_element_first'.$form_id.'" value="'.(count($element_value)==2 ? $element_value[0] : $element_value[1]).'" style="width:100%;"></div>
						  <div><label class="mini_label">'.$w_mini_labels[1].'</label></div>
						</div>
						<div style="display:table-cell;"><div style="margin: 0px 4px; padding: 0px;"></div></div>
						<div style="display: table-cell; width:30%">
						  <div><input type="text" class="" id="wdform_'.$id1.'_element_last'.$form_id.'" name="wdform_'.$id1.'_element_last'.$form_id.'" value="'.(count($element_value)==2 ? $element_value[1] : $element_value[2]).'" style="width:  100%;"></div>
						  <div><label class="mini_label">'.$w_mini_labels[2].'</label></div>
						</div>';
					$w_size = 2*$param['w_size'];
					
					if($w_name_fields[0] == 'yes') {
						$w_name_format = '
							<div style="display: table-cell;">
							  <div><input type="text" class="" id="wdform_'.$id1.'_element_title'.$form_id.'" name="wdform_'.$id1.'_element_title'.$form_id.'" value="'.(count($element_value)==2 ? "" : $element_value[0]).'" style="width: 40px;"></div>
							  <div><label class="mini_label">'.$w_mini_labels[0].'</label></div>
							</div>
							<div style="display:table-cell;"><div style="margin: 0px 1px; padding: 0px;"></div></div>'.$w_name_format;
						$w_size	+= 80;
					}
					if($w_name_fields[1] == 'yes') {
						$w_name_format = $w_name_format.'
							<div style="display:table-cell;"><div style="margin: 0px 4px; padding: 0px;"></div></div>
							<div style="display: table-cell; width:30%">
							  <div><input type="text" class="" id="wdform_'.$id1.'_element_middle'.$form_id.'" name="wdform_'.$id1.'_element_middle'.$form_id.'" value="'.(count($element_value)==2 ? "" : $element_value[3]).'"style="width: 100%;"></div>
							  <div><label class="mini_label">'.$w_mini_labels[3].'</label></div>
							</div>						
							';
						$w_size	+= $param['w_size'];		
					}		
				}
				
                $wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$w_size) : max($param['w_field_label_size'],$w_size));	
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	

                $rep ='<div type="type_name" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div>
                <div class="wdform-element-section '.$param['w_class'].'" style="width: '.$w_size.'px;">'.$w_name_format.'</div></div>';
        
              break;
            }
            
            case 'type_address': {
              $params_names = array('w_field_label_size','w_field_label_pos','w_size','w_mini_labels','w_disabled_fields','w_required','w_class');
              $temp = $params;
              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
              
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']) : max($param['w_field_label_size'], $param['w_size']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
              $w_mini_labels = explode('***',$param['w_mini_labels']);
              $w_disabled_fields = explode('***',$param['w_disabled_fields']);
            
              $rep ='<div type="type_address" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';		
          
              $address_fields ='';
              $g=0;
              if (isset($w_disabled_fields[0]) && $w_disabled_fields[0]=='no') {
                  $g+=2;
                  $address_fields .= '<span style="float: left; width: 100%; padding-bottom: 8px; display: block;"><input type="text" id="wdform_'.$id1.'_street1'.$form_id.'" name="wdform_'.$id1.'_street1'.$form_id.'" value="'.$elements_of_address[0].'" style="width: 100%;" '.$param['attributes'].'><label class="mini_label" >'.$w_mini_labels[0].'</label></span>';
              }
              if (isset($w_disabled_fields[1]) && $w_disabled_fields[1]=='no') {
                $g+=2;
                $address_fields .= '<span style="float: left; width: 100%; padding-bottom: 8px; display: block;"><input type="text" id="wdform_'.$id1.'_street2'.$form_id.'" name="wdform_'.($id1+1).'_street2'.$form_id.'" value="'.$elements_of_address[1].'" style="width: 100%;" '.$param['attributes'].'><label class="mini_label" >'.$w_mini_labels[1].'</label></span>';
              }
              if (isset($w_disabled_fields[2]) && $w_disabled_fields[2]=='no') {
                $g++;
                $address_fields .= '<span style="float: left; width: 48%; padding-bottom: 8px;"><input type="text" id="wdform_'.$id1.'_city'.$form_id.'" name="wdform_'.($id1+2).'_city'.$form_id.'" value="'.$elements_of_address[2].'" style="width: 100%;" '.$param['attributes'].'><label class="mini_label" >'.$w_mini_labels[2].'</label></span>';
              }
              if (isset($w_disabled_fields[3]) && $w_disabled_fields[3]=='no') {
                $g++;												
                $w_states = array("","Alabama","Alaska", "Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District Of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");	
                $w_state_options = '';
                foreach($w_states as $w_state) {						
                  if($w_state == $elements_of_address[3])					
                    $selected = 'selected=\"selected\"';
                  else
                    $selected = '';
                  $w_state_options .= '<option value="'.$w_state.'" '.$selected.'>'.$w_state.'</option>';
                }
                if(isset($w_disabled_fields[5]) && $w_disabled_fields[5]=='yes' && isset($w_disabled_fields[6]) && $w_disabled_fields[6]=='yes') {
                  $address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><select type="text" id="wdform_'.$id1.'_state'.$form_id.'" name="wdform_'.($id1+3).'_state'.$form_id.'" style="width: 100%;" '.$param['attributes'].'>'.$w_state_options.'</select><label class="mini_label" style="display: block;" id="'.$id1.'_mini_label_state">'.$w_mini_labels[3].'</label></span>';
                }
                else
                  $address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><input type="text" id="wdform_'.$id1.'_state'.$form_id.'" name="wdform_'.($id1+3).'_state'.$form_id.'" value="'.$elements_of_address[3].'" style="width: 100%;" '.$param['attributes'].'><label class="mini_label">'.$w_mini_labels[3].'</label></span>';
              }
              if (isset($w_disabled_fields[4]) && $w_disabled_fields[4]=='no') {
                $g++;
                $address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><input type="text" id="wdform_'.$id1.'_postal'.$form_id.'" name="wdform_'.($id1+4).'_postal'.$form_id.'" value="'.$elements_of_address[4].'" style="width: 100%;" '.$param['attributes'].'><label class="mini_label">'.$w_mini_labels[4].'</label></span>';
              }
              $w_countries = array("","Afghanistan","Albania","Algeria","Andorra","Angola","Antigua and Barbuda","Argentina","Armenia","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Brazil","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Central African Republic","Chad","Chile","China","Colombia","Comoros","Congo (Brazzaville)","Congo","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","East Timor (Timor Timur)","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Fiji","Finland","France","Gabon","Gambia, The","Georgia","Germany","Ghana","Greece","Grenada","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Honduras","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Korea, North","Korea, South","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Mauritania","Mauritius","Mexico","Micronesia","Moldova","Monaco","Mongolia","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Zealand","Nicaragua","Niger","Nigeria","Norway","Oman","Pakistan","Palau","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Poland","Portugal","Qatar","Romania","Russia","Rwanda","Saint Kitts and Nevis","Saint Lucia","Saint Vincent","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","Spain","Sri Lanka","Sudan","Suriname","Swaziland","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Togo","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Yemen","Zambia","Zimbabwe");	
              $w_options = '';
              foreach($w_countries as $w_country) {
                if($w_country == $elements_of_address[5])					
                  $selected = 'selected="selected"';
                else
                  $selected = '';
                $w_options .= '<option value="'.$w_country.'" '.$selected.'>'.$w_country.'</option>';
              }
            
              if (isset($w_disabled_fields[5]) && $w_disabled_fields[5]=='no') {
                $g++;
                $address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;display: inline-block;"><select type="text" id="wdform_'.$id1.'_country'.$form_id.'" name="wdform_'.($id1+5).'_country'.$form_id.'" style="width:100%" '.$param['attributes'].'>'.$w_options.'</select><label class="mini_label">'.$w_mini_labels[5].'</span>';
              }				

            
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size'].'px;"><div>
              '.$address_fields.'</div></div></div>';	
              break;
            }

            case 'type_submitter_mail': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_required','w_unique', 'w_class');
              $temp=$params;

              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              
              
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
              
              
              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']) : max($param['w_field_label_size'], $param['w_size']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
              $rep ='<div type="type_submitter_mail" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size'].'px;"><input type="text" class="" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$element_value.'" title="'.$param['w_title'].'"  style="width: 100%;" '.$param['attributes'].'></div></div>';
              
            
              
              break;
            }

            case 'type_checkbox':

					{

					

						$params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');

						$temp=$params;

						if(strpos($temp, 'w_field_option_pos') > -1)

							$params_names=array('w_field_label_size','w_field_label_pos','w_field_option_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_value_disabled','w_choices_value', 'w_choices_params', 'w_class');

							

						foreach($params_names as $params_name )

						{	

							$temp=explode('*:*'.$params_name.'*:*',$temp);

							$param[$params_name] = $temp[0];

							$temp=$temp[1];

						}

						

						if($temp)

						{	

							$temp	=explode('*:*w_attr_name*:*',$temp);

							$attrs	= array_slice($temp,0, count($temp)-1);   

							foreach($attrs as $attr)

								$param['attributes'] = $param['attributes'].' '.$attr;

						}

						

						$param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	

						if(!isset($param['w_value_disabled']))

						$param['w_value_disabled'] = 'no';

						

						if(!isset($param['w_field_option_pos']))

						$param['w_field_option_pos'] = 'left';

						

						$param['w_field_option_pos1'] = ($param['w_field_option_pos']=="right" ? "style='float: none !important;'" : "");

						$param['w_field_option_pos2'] = ($param['w_field_option_pos']=="right" ? "style='float: left !important; margin-right: 8px !important; display: inline-block !important;'" : "");	

						

						$param['w_choices']	= explode('***',$param['w_choices']);

						if(isset($param['w_choices_value']))

						{

							$param['w_choices_value'] = explode('***',$param['w_choices_value']);

							$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

						}

						

						$element_value	= explode('***br***',$element_value);

						$element_value 	= array_slice($element_value,0, count($element_value)-1); 

						$is_other=false;

						$other_value = '';



						foreach($element_value as $key => $value)

						{

							if(!in_array($value, ($param['w_value_disabled']=='no' ? $param['w_choices'] : (isset($param['w_choices_value']) ? $param['w_choices_value'] : array()))))

							{

								$other_value = $value;

								$is_other=true;

								break;

							}

						}



						$rep='<div type="type_checkbox" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

						$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';">';

					

						$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).'; vertical-align:top">';

						$total_queries = 0;

						foreach($param['w_choices'] as $key => $choice)

						{	

							$key1 = $key + $total_queries;

							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

							{	

							$choices_labels =array();
							$choices_values = array();

							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							
							$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
							$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
						
		

								$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

								$table = $label_table_and_column[0];

								$label_column = $label_table_and_column[1];

								if($label_column)

								{
								$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);					

								}	



								$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_value'][$key]));

								$value_column = $value_table_and_column[1];



								if($value_column)

								{
								$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

								}		

								$columns_count_checkbox = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

								

								if(array_filter($choices_labels) || array_filter($choices_values))

								{

									$total_queries = $total_queries + $columns_count_checkbox-1;

									

									if(!isset($post_value))

										$param['w_choices_checked'][$key]=($param['w_choices_checked'][$key]=='true' ? 'checked="checked"' : '');

										

									for($k=0; $k<$columns_count_checkbox; $k++)

									{

										$choice_label = isset($choices_labels[$k]) ? $choices_labels[$k] : '';

										$choice_value = isset($choices_values[$k]) ? $choices_values[$k] : $choice_label;

										if(($key1+$k)%$param['w_rowcol']==0 && ($key1+$k)>0)

											$rep.='</div><div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';  vertical-align:top">';

										

										$checked=(in_array($choice_value, $element_value) ? 'checked="checked"' : '');

										

										$rep.='<div style="display: '.($param['w_flow']!='hor' ? 'table-cell' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" '.$param['w_field_option_pos1'].'>'.$choice_label.'</label><div class="checkbox-div forlabs" '.$param['w_field_option_pos2'].'><input type="checkbox" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'other="1"' : ''	).' id="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" name="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" value="'.htmlspecialchars($choice_value).'" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'onclick="if(set_checked(&quot;wdform_'.$id1.'&quot;,&quot;'.($key1+$k).'&quot;,&quot;'.$form_id.'&quot;)) show_other_input(&quot;wdform_'.$id1.'&quot;,&quot;'.$form_id.'&quot;);"' : '').' '.$param['attributes'].' '.$checked.'><label for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'"></label></div></div>';

										

									}

								}	

							}	

							else

							{

								if($key1%$param['w_rowcol']==0 && $key1>0)

									$rep.='</div><div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';  vertical-align:top">';

									

								$checked=(in_array($choice, $element_value) ? 'checked="checked"' : '');

								

								if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key && $is_other)

									$checked = 'checked="checked"';	

									

								

								$rep.='<div style="display: '.($param['w_flow']!='hor' ? 'table-cell' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.$key1.'" '.$param['w_field_option_pos1'].'>'.$choice.'</label><div class="checkbox-div forlabs" '.$param['w_field_option_pos2'].'><input type="checkbox" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'other="1"' : ''	).' id="wdform_'.$id1.'_element'.$form_id.''.$key1.'" name="wdform_'.$id1.'_element'.$form_id.''.$key1.'" value="'.htmlspecialchars($choice).'" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'onclick="if(set_checked(&quot;wdform_'.$id1.'&quot;,&quot;'.$key1.'&quot;,&quot;'.$form_id.'&quot;)) show_other_input(&quot;wdform_'.$id1.'&quot;,&quot;'.$form_id.'&quot;);"' : '').' '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.$key1.'"></label></div></div>';

								

								$param['w_allow_other_num'] = $param['w_allow_other_num']==$key ? $key1 : $param['w_allow_other_num'];

							}	

						}

						$rep.='</div>';



						$rep.='</div></div>';

						

						

						if($is_other)

							$onload_js .='show_other_input("wdform_'.$id1.'","'.$form_id.'"); jQuery("#wdform_'.$id1.'_other_input'.$form_id.'").val("'.$other_value.'");';

						

						$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_allow_other'.$form_id.'\" value = \"'.$param['w_allow_other'].'\" />").appendTo("#adminForm");

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_allow_other_num'.$form_id.'\" value = \"'.$param['w_allow_other_num'].'\" />").appendTo("#adminForm");

							';

							

						break;

					}

            case 'type_radio':

					{

					

						

						$params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');

						$temp=$params;

						if(strpos($temp, 'w_field_option_pos') > -1)

						$params_names=array('w_field_label_size','w_field_label_pos','w_field_option_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num','w_value_disabled','w_choices_value', 'w_choices_params','w_class');

						

						foreach($params_names as $params_name )

						{	

							$temp=explode('*:*'.$params_name.'*:*',$temp);

							$param[$params_name] = $temp[0];

							$temp=$temp[1];

						}

						

						if($temp)

						{	

							$temp	=explode('*:*w_attr_name*:*',$temp);

							$attrs	= array_slice($temp,0, count($temp)-1);   

							foreach($attrs as $attr)

								$param['attributes'] = $param['attributes'].' '.$attr;

						}

						if(!isset($param['w_value_disabled']))

							$param['w_value_disabled'] = 'no';

					

						if(!isset($param['w_field_option_pos']))

							$param['w_field_option_pos'] = 'left';

						

						$param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	

						$param['w_field_option_pos1'] = ($param['w_field_option_pos']=="right" ? "style='float: none !important;'" : "");

						$param['w_field_option_pos2'] = ($param['w_field_option_pos']=="right" ? "style='float: left !important; margin-right: 8px !important; display: inline-block !important;'" : "");

					

						$param['w_choices']	= explode('***',$param['w_choices']);

						if(isset($param['w_choices_value']))

						{

							$param['w_choices_value'] = explode('***',$param['w_choices_value']);

							$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

						}

						

						$is_other=true;



						foreach($param['w_choices'] as $key => $choice)

						{

							$choice_value = isset($param['w_choices_value']) ? $param['w_choices_value'][$key] : $choice;	

							if($choice_value==$element_value)

							{

								$is_other=false;

								break;

							}

						}	

											

						$rep='<div type="type_radio" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

						$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';">';

					

						$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).'; vertical-align:top">';

						$total_queries =0;

						foreach($param['w_choices'] as $key => $choice)

						{	

							$key1 = $key + $total_queries;

							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

							{	

								$choices_labels =array();	
							$choices_values =array();	
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
							$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
	
								$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

								$table = $label_table_and_column[0];

								$label_column = $label_table_and_column[1];

								if($label_column) {
									$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);
								}



								$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_value'][$key]));

								$value_column = $value_table_and_column[1];



								if($value_column) {
                  $choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);
								}	

								

								$columns_count_radio = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

								if(array_filter($choices_labels) || array_filter($choices_values))

								{

									$total_queries = $total_queries + $columns_count_radio-1;

				

									for($k=0; $k<$columns_count_radio; $k++)

									{

										$choice_label = isset($choices_labels[$k]) ? $choices_labels[$k] : '';

										$choice_value = isset($choices_values[$k]) ? $choices_values[$k] : $choice_label;

											

										if(($key1+$k)%$param['w_rowcol']==0 && ($key1+$k)>0)

											$rep.='</div><div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';  vertical-align:top">';



										$checked =($choice_value==$element_value ? 'checked="checked"' : '');

										if($choice_value==$element_value)

											$is_other=false;

										

										$rep.='<div style="display: '.($param['w_flow']!='hor' ? 'table-cell' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" '.$param['w_field_option_pos1'].'>'.$choice_label.'</label><div class="radio-div forlabs" '.$param['w_field_option_pos2'].'><input type="radio" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'other="1"' : ''	).' id="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.htmlspecialchars($choice_value).'" onclick="set_default(&quot;wdform_'.$id1.'&quot;,&quot;'.($key1+$k).'&quot;,&quot;'.$form_id.'&quot;); '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'show_other_input(&quot;wdform_'.$id1.'&quot;,&quot;'.$form_id.'&quot;);' : '').'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'"></label></div></div>';

					

									}

								}	

							}	

							else

							{

								if($key1%$param['w_rowcol']==0 && $key1>0)

									$rep.='</div><div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';  vertical-align:top">';

								

								$checked =($choice==$element_value ? 'checked="checked"' : '');

								if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key && $is_other==true && $element_value!='')

									$checked = 'checked="checked"';

								$choice_value = isset($param['w_choices_value']) ? $param['w_choices_value'][$key] : $choice;

								

								$rep.='<div style="display: '.($param['w_flow']!='hor' ? 'table-cell' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.$key1.'" '.$param['w_field_option_pos1'].'>'.$choice.'</label><div class="radio-div forlabs" '.$param['w_field_option_pos2'].'><input type="radio" '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'other="1"' : ''	).' id="wdform_'.$id1.'_element'.$form_id.''.$key1.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.htmlspecialchars($choice_value).'" onclick="set_default(&quot;wdform_'.$id1.'&quot;,&quot;'.$key1.'&quot;,&quot;'.$form_id.'&quot;); '.(($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$key) ? 'show_other_input(&quot;wdform_'.$id1.'&quot;,&quot;'.$form_id.'&quot;);' : '').'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.$key1.'"></label></div></div>';

								

								$param['w_allow_other_num'] = $param['w_allow_other_num']==$key ? $key1 : $param['w_allow_other_num'];

							}	

						}

								$rep.='</div>';



						$rep.='</div></div>';

					

						

						if($is_other && $element_value!='') 

							$onload_js .='show_other_input("wdform_'.$id1.'","'.$form_id.'"); jQuery("#wdform_'.$id1.'_other_input'.$form_id.'").val("'.$element_value.'");';

						

						$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_allow_other'.$form_id.'\" value = \"'.$param['w_allow_other'].'\" />").appendTo("#form'.$form_id.'");

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_allow_other_num'.$form_id.'\" value = \"'.$param['w_allow_other_num'].'\" />").appendTo("#adminForm");

							';

						

						break;

					}

            case 'type_own_select':

					{

					

						$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_checked', 'w_choices_disabled','w_required','w_class');

						$temp=$params;

						if(strpos($temp, 'w_choices_value') > -1)

						$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_checked', 'w_choices_disabled', 'w_required', 'w_value_disabled', 'w_choices_value', 'w_choices_params', 'w_class');

						

						foreach($params_names as $params_name )

						{	

							$temp=explode('*:*'.$params_name.'*:*',$temp);

							$param[$params_name] = $temp[0];

							$temp=$temp[1];

						}

						

						

						if($temp)

						{	

							$temp	=explode('*:*w_attr_name*:*',$temp);

							$attrs	= array_slice($temp,0, count($temp)-1);   

							foreach($attrs as $attr)

								$param['attributes'] = $param['attributes'].' '.$attr;

						}

						

					

						$wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']) : max($param['w_field_label_size'], $param['w_size']));	

						$param['w_field_label_pos1'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "");	

						$param['w_field_label_pos2'] = ($param['w_field_label_pos']=="left" ? "" : "display:block;");

					

						$param['w_choices']	= explode('***',$param['w_choices']);

						$param['w_choices_disabled']	= explode('***',$param['w_choices_disabled']);

						if(isset($param['w_choices_value']))

						{

							$param['w_choices_value'] = explode('***',$param['w_choices_value']);

							$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

						}

						

						if(!isset($param['w_value_disabled']))

						$param['w_value_disabled'] = 'no';

						

						$rep='<div type="type_own_select" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos1'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

						$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos2'].' width: '.($param['w_size']).'px; "><select id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" style="width: 100%;"  '.$param['attributes'].'>';

						foreach($param['w_choices'] as $key => $choice)

						{

							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

							{

								$choices_labels =array();
							$choices_values = array();
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
							$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
							
							
								$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

								$table = $label_table_and_column[0];

								$label_column = $label_table_and_column[1];

								if($label_column)

								{

									$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);

								}	



								$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_value'][$key]));

								$value_column = $param['w_choices_disabled'][$key]=="true" ? '' : $value_table_and_column[1];



								if($value_column)

								{

									$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

								}	



								$columns_count = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

								if(array_filter($choices_labels) || array_filter($choices_values))

									for($k=0; $k<$columns_count; $k++)

									{

										$choice_label = isset($choices_labels[$k]) ? $choices_labels[$k] : '';

										$choice_value = isset($choices_values[$k]) ? $choices_values[$k] : ($param['w_choices_disabled'][$key]=="true" ? '' : $choice_label);

									

										$selected=($element_value && htmlspecialchars($choice_value)==htmlspecialchars($element_value) ? 'selected="selected"' : '');



										$rep.='<option value="'.htmlspecialchars($choice_value).'" '.$selected.'>'.$choice_label.'</option>';

													

									}		

							}

							else

							{		

								$choice_value = $param['w_choices_disabled'][$key]=="true" ? '' : (isset($param['w_choices_value']) ? $param['w_choices_value'][$key] : $choice);

								

								$selected=($element_value && htmlspecialchars($choice_value)==htmlspecialchars($element_value) ? 'selected="selected"' : '');

	

								$rep.='<option value="'.htmlspecialchars($choice_value).'" '.$selected.'>'.$choice.'</option>';

							}  

						}

						$rep.='</select></div></div>';

						

						

						break;

					}
            
            case 'type_country': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_countries','w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']) : max($param['w_field_label_size'], $param['w_size']));	
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
              $param['w_countries']	= explode('***',$param['w_countries']);
              
              $selected='';
     
              $rep='<div type="type_country" class="wdform-field"  style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
              $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="width: '.$param['w_size'].'px;"><select id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" style="width: 100%;"  '.$param['attributes'].'>';
              foreach($param['w_countries'] as $key => $choice) {
                
                  $selected=(htmlspecialchars($choice)==htmlspecialchars($element_value) ? 'selected="selected"' : '');

                $choice_value=$choice;
                $rep.='<option value="'.$choice_value.'" '.$selected.'>'.$choice.'</option>';
              }
              $rep.='</select></div></div>';
                          
              break;
            }
            
            case 'type_time': {
              if($element_value =='')
                $element_value = ':';
                
                $params_names=array('w_field_label_size','w_field_label_pos','w_time_type','w_am_pm','w_sec','w_hh','w_mm','w_ss','w_mini_labels','w_required','w_class');
                $temp=$params;

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }
                
                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
              
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
                $w_mini_labels = explode('***',$param['w_mini_labels']);
                $element_value = explode(':',$element_value);
              
              
                $w_sec = '';
                $w_sec_label='';
                
                if($param['w_sec']=='1') {
                  $w_sec = '<div align="center" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;:&nbsp;</span></div><div style="display: table-cell;"><input type="text" value="'.(count($element_value)==2 ? '' : $element_value[2]).'" class="time_box" id="wdform_'.$id1.'_ss'.$form_id.'" name="wdform_'.$id1.'_ss'.$form_id.'" onkeypress="return check_second(event, &quot;wdform_'.$id1.'_ss'.$form_id.'&quot;)" '.$param['attributes'].'></div>';
                  
                  $w_sec_label='<div style="display: table-cell;"></div><div style="display: table-cell;"><label class="mini_label">'.$w_mini_labels[2].'</label></div>';
                }

                
                if($param['w_time_type']=='12') {
                  if(strpos($element_value[2],'pm')!==false) {
                    $am_ = "";
                    $pm_ = "selected=\"selected\"";	
                  }	
                  else {
                    $am_ = "selected=\"selected\"";
                    $pm_ = "";	
                  }	
                
                    $w_time_type = '<div style="display: table-cell;"><select class="am_pm_select" name="wdform_'.$id1.'_am_pm'.$form_id.'" id="wdform_'.$id1.'_am_pm'.$form_id.'" '.$param['attributes'].'><option value="am" '.$am_.'>AM</option><option value="pm" '.$pm_.'>PM</option></select></div>';
                
                    $w_time_type_label = '<div ><label class="mini_label">'.$w_mini_labels[3].'</label></div>';
                
                }
                else {
                  $w_time_type='';
                  $w_time_type_label = '';
                }
                          
                $rep ='<div type="type_time" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';"><div style="display: table;"><div style="display: table-row;"><div style="display: table-cell;"><input type="text" value="'.$element_value[0].'" class="time_box" id="wdform_'.$id1.'_hh'.$form_id.'" name="wdform_'.$id1.'_hh'.$form_id.'" onkeypress="return check_hour(event, &quot;wdform_'.$id1.'_hh'.$form_id.'&quot;, &quot;23&quot;)" '.$param['attributes'].'></div><div align="center" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;:&nbsp;</span></div><div style="display: table-cell;"><input type="text" value="'.$element_value[1].'" class="time_box" id="wdform_'.$id1.'_mm'.$form_id.'" name="wdform_'.$id1.'_mm'.$form_id.'" onkeypress="return check_minute(event, &quot;wdform_'.$id1.'_mm'.$form_id.'&quot;)" '.$param['attributes'].'></div>'.$w_sec.$w_time_type.'</div><div style="display: table-row;"><div style="display: table-cell;"><label class="mini_label">'.$w_mini_labels[0].'</label></div><div style="display: table-cell;"></div><div style="display: table-cell;"><label class="mini_label">'.$w_mini_labels[1].'</label></div>'.$w_sec_label.$w_time_type_label.'</div></div></div></div>';
                                
              break;
            }

            case 'type_date': {
                $params_names=array('w_field_label_size','w_field_label_pos','w_date','w_required','w_class','w_format','w_but_val');
                $temp = $params;
			    if(strpos($temp, 'w_disable_past_days') > -1)
				  $params_names = array('w_field_label_size','w_field_label_pos','w_date','w_required','w_class','w_format','w_but_val', 'w_disable_past_days');

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }
                              
                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
                              
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                $rep ='<div type="type_date" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';"><input type="text" value="'.$element_value.'" class="wdform-date" id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" maxlength="10" '.$param['attributes'].'><input id="wdform_'.$id1.'_button'.$form_id.'" class="wdform-calendar-button" type="reset" value="'.$param['w_but_val'].'" format="'.$param['w_format'].'" onclick="return showCalendar(\'wdform_'.$id1.'_element'.$form_id.'\' , \'%Y-%m-%d\')"  '.$param['attributes'].' "></div></div>';
        
                
                // $onload_js.= 'Calendar.setup({inputField: "wdform_'.$id1.'_element'.$form_id.'",	ifFormat: "'.$param['w_format'].'",button: "wdform_'.$id1.'_button'.$form_id.'",align: "Tl",singleClick: true,firstDay: 0});';
                
              break;
            }

            case 'type_date_fields': {
              if($element_value=='')
                $element_value='--';
                
                $params_names=array('w_field_label_size','w_field_label_pos','w_day','w_month','w_year','w_day_type','w_month_type','w_year_type','w_day_label','w_month_label','w_year_label','w_day_size','w_month_size','w_year_size','w_required','w_class','w_from','w_to','w_divider');
                
                $temp=$params;

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }
                
                
                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
                
                $element_value = explode('-',$element_value); 
                
                $param['w_day'] = (isset($_POST['wdform_'.$id1."_day".$form_id]) ? esc_html(stripslashes( $_POST['wdform_'.$id1."_day".$form_id])) : $param['w_day']);
                $param['w_month'] = (isset($_POST['wdform_'.$id1."_month".$form_id]) ? esc_html(stripslashes( $_POST['wdform_'.$id1."_month".$form_id])) : $element_value[1]);//??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
                $param['w_year'] = (isset($_POST['wdform_'.$id1."w_year".$form_id]) ? esc_html(stripslashes( $_POST['wdform_'.$id1."_year".$form_id])) : $param['w_year']);
                  
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                if($param['w_day_type']=="SELECT") {
                
                  $w_day_type = '<select id="wdform_'.$id1.'_day'.$form_id.'" name="wdform_'.$id1.'_day'.$form_id.'" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].'><option value=""></option>';
                  
                  for($k=1; $k<=31; $k++) {
                  
                    if($k<10) {
                      if($element_value[0]=='0'.$k)
                      $selected = "selected=\"selected\"";
                      else
                      $selected = "";
                      
                      $w_day_type .= '<option value="0'.$k.'" '.$selected.'>0'.$k.'</option>';
                    }
                    else {
                      if($element_value[0]==''.$k)
                      $selected = "selected=\"selected\"";
                      else
                      $selected = "";
                      
                      $w_day_type .= '<option value="'.$k.'" '.$selected.'>'.$k.'</option>';
                    }
                    
                  }
                  $w_day_type .= '</select>';
                  
                }
                else {
                  $w_day_type = '<input type="text" value="'.$element_value[0].'" id="wdform_'.$id1.'_day'.$form_id.'" name="wdform_'.$id1.'_day'.$form_id.'" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].'>';
                  $onload_js .='jQuery("#wdform_'.$id1.'_day'.$form_id.'").blur(function() {if (jQuery(this).val()=="0") jQuery(this).val(""); else add_0(this)});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_day'.$form_id.'").keypress(function() {return check_day(event, this)});';
                }
                
                
                if($param['w_month_type']=="SELECT") {
                
                      $w_month_type = '<select id="wdform_'.$id1.'_month'.$form_id.'" name="wdform_'.$id1.'_month'.$form_id.'" style="width: '.$param['w_month_size'].'px;" '.$param['attributes'].'><option value=""></option><option value="01" '.($param['w_month']=="01" ? "selected=\"selected\"": "").'  >'.(__("January", 'form_maker')).'</option><option value="02" '.($param['w_month']=="02" ? "selected=\"selected\"": "").'>'.(__("February", 'form_maker')).'</option><option value="03" '.($param['w_month']=="03"? "selected=\"selected\"": "").'>'.(__("March", 'form_maker')).'</option><option value="04" '.($param['w_month']=="04" ? "selected=\"selected\"": "").' >'.(__("April", 'form_maker')).'</option><option value="05" '.($param['w_month']=="05" ? "selected=\"selected\"": "").' >'.(__("May", 'form_maker')).'</option><option value="06" '.($param['w_month']=="06" ? "selected=\"selected\"": "").' >'.(__("June", 'form_maker')).'</option><option value="07" '.($param['w_month']=="07" ? "selected=\"selected\"": "").' >'.(__("July", 'form_maker')).'</option><option value="08" '.($param['w_month']=="08" ? "selected=\"selected\"": "").' >'.(__("August", 'form_maker')).'</option><option value="09" '.($param['w_month']=="09" ? "selected=\"selected\"": "").' >'.(__("September", 'form_maker')).'</option><option value="10" '.($param['w_month']=="10" ? "selected=\"selected\"": "").' >'.(__("October", 'form_maker')).'</option><option value="11" '.($param['w_month']=="11" ? "selected=\"selected\"": "").'>'.(__("November", 'form_maker')).'</option><option value="12" '.($param['w_month']=="12" ? "selected=\"selected\"": "").' >'.(__("December", 'form_maker')).'</option></select>';              
                }
                else {
                  $w_month_type = '<input type="text" value="'.$element_value[1].'" id="wdform_'.$id1.'_month'.$form_id.'" name="wdform_'.$id1.'_month'.$form_id.'"  style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].'>';
                  $onload_js .='jQuery("#wdform_'.$id1.'_month'.$form_id.'").blur(function() {if (jQuery(this).val()=="0") jQuery(this).val(""); else add_0(this)});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_month'.$form_id.'").keypress(function() {return check_month(event, this)});';
                }
                
                
                if($param['w_year_type']=="SELECT" ) {
                  $w_year_type = '<select id="wdform_'.$id1.'_year'.$form_id.'" name="wdform_'.$id1.'_year'.$form_id.'"  from="'.$param['w_from'].'" to="'.$param['w_to'].'" style="width: '.$param['w_year_size'].'px;" '.$param['attributes'].'><option value=""></option>';
                  
                  for($k=$param['w_to']; $k>=$param['w_from']; $k--) {
                    if($element_value[2]==$k)
                    $selected = "selected=\"selected\"";
                    else
                    $selected = "";
                    
                    $w_year_type .= '<option value="'.$k.'" '.$selected.'>'.$k.'</option>';
                  }
                  $w_year_type .= '</select>';
                }
                else {
                  $w_year_type = '<input type="text" value="'.$element_value[2].'" id="wdform_'.$id1.'_year'.$form_id.'" name="wdform_'.$id1.'_year'.$form_id.'" from="'.$param['w_from'].'" to="'.$param['w_to'].'" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].'>';
                  $onload_js .='jQuery("#wdform_'.$id1.'_year'.$form_id.'").blur(function() {check_year2(this)});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_year'.$form_id.'").keypress(function() {return check_year1(event, this)});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_year'.$form_id.'").change(function() {change_year(this)});';
                }
                  
                $rep ='<div type="type_date_fields" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';"><div style="display: table;"><div style="display: table-row;"><div style="display: table-cell;">'.$w_day_type.'</div><div style="display: table-cell;"><span class="wdform_separator">'.$param['w_divider'].'</span></div><div style="display: table-cell;">'.$w_month_type.'</div><div style="display: table-cell;"><span class="wdform_separator">'.$param['w_divider'].'</span></div><div style="display: table-cell;">'.$w_year_type.'</div></div><div style="display: table-row;"><div style="display: table-cell;"><label class="mini_label">'.$param['w_day_label'].'</label></div><div style="display: table-cell;"></div><div style="display: table-cell;"><label class="mini_label" >'.$param['w_month_label'].'</label></div><div style="display: table-cell;"></div><div style="display: table-cell;"><label class="mini_label">'.$param['w_year_label'].'</label></div></div></div></div></div>';
                 
              break;
            }
    
            
            case 'type_hidden': {
              $params_names=array('w_name','w_value');
              $temp=$params;

              foreach($params_names as $params_name ) {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
                
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' '.$attr;
              }
              
              $rep ='<div type="type_hidden" class="wdform-field"><div class="wdform-label-section" style="float:left; width: 150px;"><span class="wdform-label">' . $label . '</span></div><div class="wdform-element-section" style="display: table-cell;"><input type="text" value="'.$element_value.'" id="wdform_'.$id1.'_element'.$form_id.'" name="'.$param['w_name'].'" '.$param['attributes'].'></div></div>';
              
              break;
            }


            case 'type_paypal_price': {
              
                $params_names=array('w_field_label_size','w_field_label_pos','w_first_val','w_title', 'w_mini_labels','w_size','w_required','w_hide_cents','w_class','w_range_min','w_range_max');
                $temp=$params;

                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }
                
                
                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' '.$attr;
                }
                
                if (strpos($element_value,'.')!== false)
                  $element = explode('.',$element_value);
                else {
                  $element = Array();
                  $element[0] = preg_replace("/[^0-9]/","",$element_value);
                  $element[1] = '';
                }
                  
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                $hide_cents = ($param['w_hide_cents']=="yes" ? "none;" : "table-cell;");	
                          
                $w_mini_labels = explode('***',$param['w_mini_labels']);
                
                $rep ='<div type="type_paypal_price" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                 
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';"><input type="hidden" value="'.$param['w_range_min'].'" name="wdform_'.$id1.'_range_min'.$form_id.'" id="wdform_'.$id1.'_range_min'.$form_id.'"><input type="hidden" value="'.$param['w_range_max'].'" name="wdform_'.$id1.'_range_max'.$form_id.'" id="wdform_'.$id1.'_range_max'.$form_id.'"><div id="wdform_'.$id1.'_table_price" style="display: table;"><div id="wdform_'.$id1.'_tr_price1" style="display: table-row;"><div id="wdform_'.$id1.'_td_name_currency" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;"><!--repstart-->&nbsp;'.$form_currency.'&nbsp;<!--repend--></span></div><div id="wdform_'.$id1.'_td_name_dollars" style="display: table-cell;"><input type="text" class="" id="wdform_'.$id1.'_element_dollars'.$form_id.'" name="wdform_'.$id1.'_element_dollars'.$form_id.'" value="'.(strpos($element_value,'.') !== false ? preg_replace("/[^0-9]/","",$element[0]) : $element[0]).'"  onkeypress="return check_isnum(event)" style="width: '.$param['w_size'].'px;" '.$param['attributes'].'></div><div id="wdform_'.$id1.'_td_name_divider" style="display: '.$hide_cents.';"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;.&nbsp;</span></div><div id="wdform_'.$id1.'_td_name_cents" style="display: '.$hide_cents.'"><input type="text" class="" id="wdform_'.$id1.'_element_cents'.$form_id.'" name="wdform_'.$id1.'_element_cents'.$form_id.'" value="'.(strpos($element_value,'.') !== false ? preg_replace("/[^0-9]/","",$element[1]) : " ").'"  style="width: 30px;" '.$param['attributes'].'></div></div><div id="wdform_'.$id1.'_tr_price2" style="display: table-row;"><div style="display: table-cell;"><label class="mini_label"></label></div><div align="left" style="display: table-cell;"><label class="mini_label">'.$w_mini_labels[0].'</label></div><div id="wdform_'.$id1.'_td_name_label_divider" style="display: '.$hide_cents.'"><label class="mini_label"></label></div><div align="left" id="wdform_'.$id1.'_td_name_label_cents" style="display: '.$hide_cents.'"><label class="mini_label">'.$w_mini_labels[1].'</label></div></div></div></div></div>';
                
                $onload_js .='jQuery("#wdform_'.$id1.'_element_cents'.$form_id.'").blur(function() {add_0(this)});';
                $onload_js .='jQuery("#wdform_'.$id1.'_element_cents'.$form_id.'").keypress(function() {return check_isnum_interval(event,this,0,99)});';
                
              break;
            }
            
            case 'type_paypal_select':

					{



						if($element_value=='')

							$element_value = ' :';

						

						$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_price','w_choices_checked', 'w_choices_disabled','w_required','w_quantity','w_class','w_property','w_property_values');

						$temp=$params;



						if(strpos($temp, 'w_choices_params') > -1)

							$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_price','w_choices_checked', 'w_choices_disabled','w_required','w_quantity', 'w_quantity_value', 'w_choices_params','w_class','w_property','w_property_values');

							

						foreach($params_names as $params_name )

						{	

							$temp=explode('*:*'.$params_name.'*:*',$temp);

							$param[$params_name] = $temp[0];

							$temp=$temp[1];

						}

						

						

						if($temp)

						{	

							$temp	=explode('*:*w_attr_name*:*',$temp);

							$attrs	= array_slice($temp,0, count($temp)-1);   

							foreach($attrs as $attr)

								$param['attributes'] = $param['attributes'].' '.$attr;

						}

						

					

						$wdformfieldsize = ($param['w_field_label_pos']=="left" ? ($param['w_field_label_size']+$param['w_size']) : max($param['w_field_label_size'], $param['w_size']));	

						$param['w_field_label_pos1'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "");	

						$param['w_field_label_pos2'] = ($param['w_field_label_pos']=="left" ? "" : "display:block;");

						

						$param['w_choices']	= explode('***',$param['w_choices']);

						$param['w_choices_price']	= explode('***',$param['w_choices_price']);

						

						$param['w_choices_disabled']	= explode('***',$param['w_choices_disabled']);

						$param['w_property']	= explode('***',$param['w_property']);

						$param['w_property_values']	= explode('***',$param['w_property_values']);

						if(isset($param['w_choices_params']))

							$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

						

						

						if(strpos($element_value,'***br***') !== false)

						{	

							$element_value	= explode('***br***',$element_value);

							if(count($element_value)==2)

							{

								if(strpos($element_value[1],'***quantity***') !== false)

								{

									$quantity_value = explode(': ',str_replace("***quantity***","",$element_value[1]));

									$quantity_value =  $quantity_value[1];

									$property_of_select = '';

								}

								else

								{

									$quantity_value = '' ;

									$property_of_select = explode(': ',str_replace("***property***","",$element_value[1]));

									$property_of_select = $property_of_select[1];

								}

								

								$element_value	= explode(' :',$element_value[0]);

								$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

							}

							else

							{

								$quantity_value = explode(': ',str_replace("***quantity***","",$element_value[1]));

								$quantity_value =  $quantity_value[1];

								$property_of_select = explode(': ',str_replace("***property***","",$element_value[2]));

								$property_of_select = $property_of_select[1];

								$element_value	= explode(' :',$element_value[0]);

								$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

							}

						}

						else

						{

							$element_value	= explode(' :',$element_value);

							$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

							$quantity_value = '';

							$property_of_select = '';

						}

						

					

						$rep='<div type="type_paypal_select" class="wdform-field" style="width:'.$wdformfieldsize.'px"><div class="wdform-label-section" style="'.$param['w_field_label_pos1'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

						$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos2'].'; width: '.$param['w_size'].'px;"><select id="wdform_'.$id1.'_element'.$form_id.'" name="wdform_'.$id1.'_element'.$form_id.'" style="width:100%;"  '.$param['attributes'].'>';

						foreach($param['w_choices'] as $key => $choice)

						{

							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

							{

								$choices_labels =array();
								$choices_values =array();
								$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
								$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
								$w_choices_params = explode('[db_info]',$w_choices_params[1]);
								$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
								$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
			
								
								$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

								$table = $label_table_and_column[0];

								$label_column = $label_table_and_column[1];

								if($label_column)

								{

									$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);

								}	



								$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_price'][$key]));

								$value_column = $param['w_choices_disabled'][$key]=="true" ? '' : $value_table_and_column[1];



								if($value_column)

								{

									$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

								}		

								

								$columns_count = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

								

								for($k=0; $k<$columns_count; $k++)

								{

									$choice_label = isset($choices_labels[$k]) ? $choices_labels[$k] : '';

									$choice_value = isset($choices_values[$k]) ? (float)$choices_values[$k] : '';

									

									if($element_value[0] == $choice_label && $choice_value == $choise_value)

										$selected = 'selected="selected"';

									else

										$selected = '';	



									$rep.='<option value="'.$choice_value.'" '.$selected.'>'.$choice_label.'</option>';

								}			

							}

							else

							{

								if($param['w_choices_disabled'][$key]=="true")

									$choice_value='';

								else

									$choice_value=$param['w_choices_price'][$key];

									

								if($element_value[0] == $choice && $param['w_choices_price'][$key] == $choise_value)

									$selected = 'selected="selected"';

								else

									$selected = '';	

									

								$rep.='<option value="'.$choice_value.'" '.$selected.'>'.$choice.'</option>';

							

							}

						}

						$rep.='</select><div id="wdform_'.$id1.'_div'.$form_id.'">';

						if($param['w_quantity']=="yes")

						{

							$rep.='<div class="paypal-property"><label class="mini_label" style="margin: 0px 5px;">Quantity</label><input type="text" id="wdform_'.$id1.'_element_quantity'.$form_id.'" name="wdform_'.$id1.'_element_quantity'.$form_id.'" value="'.($quantity_value=="" ? 1 : $quantity_value).'"  class="wdform-quantity"></div>';

						}

						if($param['w_property'][0])					

						foreach($param['w_property'] as $key => $property)

						{

		

						$rep.='

						<div id="wdform_'.$id1.'_property_'.$key.'" class="paypal-property">

						<div style="width:150px; display:inline-block;">

						<label class="mini_label" id="wdform_'.$id1.'_property_label_'.$form_id.''.$key.'" style="margin-right: 5px;">'.$property.'</label>

						<select id="wdform_'.$id1.'_property'.$form_id.''.$key.'" name="wdform_'.$id1.'_property'.$form_id.''.$key.'" style="width: 100%; margin: 2px 0px;">';

						$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);

						$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   

						foreach($param['w_property_values'][$key] as $subkey => $property_value)

						{

							$rep.='<option id="wdform_'.$id1.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'" '.($property_of_select==$property_value ? 'selected="selected"' : "").'>'.$property_value.'</option>';

						}

						$rep.='</select></div></div>';

						}

						

						$rep.='</div></div></div>';

						



						$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_label'.$form_id.'\"  />").val(jQuery("#wdform_'.$id1.'_element'.$form_id.' option:selected").text()).appendTo("#adminForm");

							';

						$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_quantity_label'.$form_id.'\"  />").val("Quantity").appendTo("#adminForm");

								';

						$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_property_label'.$form_id.'\"  />").val("'.$param['w_property'][0].'").appendTo("#adminForm");

								';

			

					

						break;

					}
            
            case 'type_paypal_checkbox':

					{

					

							if($element_value == '')

								$element_value =' :';

											

							$params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class','w_property','w_property_values','w_quantity');

							$temp=$params;

							if(strpos($temp, 'w_field_option_pos') > -1)

								$params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_choices_params', 'w_class','w_property','w_property_values','w_quantity');	

							foreach($params_names as $params_name )

							{	

								$temp=explode('*:*'.$params_name.'*:*',$temp);

								$param[$params_name] = $temp[0];

								$temp=$temp[1];

							}

							

							

							if($temp)

							{	

								$temp	=explode('*:*w_attr_name*:*',$temp);

								$attrs	= array_slice($temp,0, count($temp)-1);   

								foreach($attrs as $attr)

									$param['attributes'] = $param['attributes'].' '.$attr;

							}

							

						

							if(!isset($param['w_field_option_pos']))

								$param['w_field_option_pos'] = 'left';

					

							$param['w_field_label_pos1'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "");	

							$param['w_field_label_pos2'] = ($param['w_field_label_pos']=="left" ? "" : "display:block;");

							$param['w_field_option_pos1'] = ($param['w_field_option_pos']=="right" ? "style='float: none !important;'" : "");

							$param['w_field_option_pos2'] = ($param['w_field_option_pos']=="right" ? "style='float: left !important; margin-right: 8px !important; display: inline-block !important;'" : "");

						

							

							$param['w_choices']	= explode('***',$param['w_choices']);

							$param['w_choices_price']	= explode('***',$param['w_choices_price']);

							

							$param['w_property']	= explode('***',$param['w_property']);

							$param['w_property_values']	= explode('***',$param['w_property_values']);

							if(isset($param['w_choices_params']))

								$param['w_choices_params'] = explode('***',$param['w_choices_params']);

							

							$rep='<div type="type_paypal_checkbox" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

							

							$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';">';

						

			

										if(strpos($element_value,'***br***') !== false)

										{	

											$element_value	= explode('***br***',$element_value);	

											foreach($element_value as $key => $element)	

											{

											

												if(strpos($element,'***quantity***') !== false)

												{

													$quantity_value = explode(': ',str_replace("***quantity***","",$element));

													$quantity_value =  $quantity_value[1];

													unset($element_value[$key]);

												}

												else

												if(strpos($element,'***property***') !== false)

												{

													$property_of_check = explode(': ',str_replace("***property***","",$element));

													$property_of_check = $property_of_check[1];

													unset($element_value[$key]);

												}

												else

												{	

													for($m=0; $m<strlen($element); $m++)

													{

														if(!ctype_digit($element[strlen($element)-1]))

															$element_value[$key] = substr($element,0,-1);

														else

															break;

													}

													$quantity_value = '';

													$property_of_check = '';

												}

												

											}

										}

										else

										{

											$element_value	= explode(' :',$element_value);

											$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

											$quantity_value = '';

											$property_of_check = '';

										}			

					

							$total_queries = 0;

							foreach($param['w_choices'] as $key => $choice)

							{

								$key1 = $key + $total_queries;

								if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

								{

									$choices_labels = array();
									$choices_values = array();
									
									$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
									$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
									$w_choices_params = explode('[db_info]',$w_choices_params[1]);
									
									$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
									$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
								
									$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

									$table = $label_table_and_column[0];

									$label_column = $label_table_and_column[1];

									if($label_column)

									{

										$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);
									}	



									$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_price'][$key]));

									$value_column = $value_table_and_column[1];



									if($value_column)

									{

										$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

									}		

									

									$columns_count = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

									

									if(array_filter($choices_labels) || array_filter($choices_values))

									{

										$total_queries = $total_queries + $columns_count-1;

										

											

										for($k=0; $k<$columns_count; $k++)

										{

											$choice_label = isset($choices_labels) ? $choices_labels[$k] : '';

											$choice_value = isset($choices_values) ? (float)$choices_values[$k] : '';

											

											$checked=(in_array($choice_label.' - '.$choice_value, $element_value)=='true' ? 'checked="checked"' : '');

											

											$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" '.$param['w_field_option_pos1'].'>'.$choice_label.'</label><div class="checkbox-div forlabs" '.$param['w_field_option_pos2'].'><input type="checkbox" id="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" name="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" value="'.$choice_value.'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'"></label></div><input type="hidden" name="wdform_'.$id1.'_element'.$form_id.($key1+$k).'_label" value="'.htmlspecialchars($choice_label).'" /></div>';

											

											

										}

									}	

								}

								else

								{

									$checked=(in_array($choice.' - '.$param['w_choices_price'][$key], $element_value)=='true' ? 'checked="checked"' : '');

									

									$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.$key1.'" '.$param['w_field_option_pos1'].'>'.$choice.'</label><div class="checkbox-div forlabs" '.$param['w_field_option_pos2'].'><input type="checkbox" id="wdform_'.$id1.'_element'.$form_id.''.$key1.'" name="wdform_'.$id1.'_element'.$form_id.''.$key1.'" value="'.$param['w_choices_price'][$key].'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.$key1.'"></label></div><input type="hidden" name="wdform_'.$id1.'_element'.$form_id.$key1.'_label" value="'.htmlspecialchars($choice).'" /></div>';

								}

							}

					

							$rep.='<div id="wdform_'.$id1.'_div'.$form_id.'">';

							if($param['w_quantity']=="yes")

								$rep.='<div class="paypal-property"><label class="mini_label" style="margin: 0px 5px;">Quantity</label><input type="text" value="'.($quantity_value == '' ? 1 : $quantity_value).'" id="wdform_'.$id1.'_element_quantity'.$form_id.'" name="wdform_'.$id1.'_element_quantity'.$form_id.'" class="wdform-quantity"></div>';

								

							if($param['w_property'][0])					

							foreach($param['w_property'] as $key => $property)

							{



							$rep.='

							<div class="paypal-property">

							<div style="width:150px; display:inline-block;">

							<label class="mini_label" id="wdform_'.$id1.'_property_label_'.$form_id.''.$key.'" style="margin-right: 5px;">'.$property.'</label>

							<select id="wdform_'.$id1.'_property'.$form_id.''.$key.'" name="wdform_'.$id1.'_property'.$form_id.''.$key.'" style="width: 100%; margin: 2px 0px;">';

							$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);

							$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   

							foreach($param['w_property_values'][$key] as $subkey => $property_value)

							{

								$rep.='<option id="wdform_'.$id1.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'" '.($property_of_check==$property_value ? 'selected="selected"' : "").'>'.$property_value.'</option>';

							}

							$rep.='</select></div></div>';

							}

							

							$rep.='</div></div></div>';

							

							$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_quantity_label'.$form_id.'\"  />").val("Quantity").appendTo("#adminForm");

							';

							$onsubmit_js.='

							jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_property_label'.$form_id.'\"  />").val("'.$param['w_property'][0].'").appendTo("#adminForm");

							';		

			

						break;

					}

            case 'type_paypal_radio':

					{

					

						if($element_value=='')

							$element_value = ' :';

						

							$params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class','w_property','w_property_values','w_quantity');

							$temp=$params;



							if(strpos($temp, 'w_field_option_pos') > -1)

								$params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_choices_params', 'w_class', 'w_property','w_property_values','w_quantity');

								

							foreach($params_names as $params_name )

							{	

								$temp=explode('*:*'.$params_name.'*:*',$temp);

								$param[$params_name] = $temp[0];

								$temp=$temp[1];

							}



							if($temp)

							{	

								$temp	=explode('*:*w_attr_name*:*',$temp);

								$attrs	= array_slice($temp,0, count($temp)-1);   

								foreach($attrs as $attr)

									$param['attributes'] = $param['attributes'].' '.$attr;

							}

							if(!isset($param['w_field_option_pos']))

								$param['w_field_option_pos'] = 'left';



							$param['w_field_label_pos1'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "");	

							$param['w_field_label_pos2'] = ($param['w_field_label_pos']=="left" ? "" : "display:block;");

							$param['w_field_option_pos1'] = ($param['w_field_option_pos']=="right" ? "style='float: none !important;'" : "");

							$param['w_field_option_pos2'] = ($param['w_field_option_pos']=="right" ? "style='float: left !important; margin-right: 8px !important; display: inline-block !important;'" : "");

							

							$param['w_choices']	= explode('***',$param['w_choices']);

							$param['w_choices_price']	= explode('***',$param['w_choices_price']);

							

							$param['w_property']	= explode('***',$param['w_property']);

							$param['w_property_values']	= explode('***',$param['w_property_values']);

							if(isset($param['w_choices_params']))

								$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

								

							$rep='<div type="type_paypal_radio" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

							$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';">';

		

							if(strpos($element_value,'***br***') !== false)

							{	

								$element_value	= explode('***br***',$element_value);

								if(count($element_value)==2)

								{

									if(strpos($element_value[1],'***quantity***') !== false)

									{

										$quantity_value = explode(': ',str_replace("***quantity***","",$element_value[1]));

										$quantity_value = $quantity_value[1];

										$property_of_radio = '';

									}

									else

									{

										$quantity_value = '' ;

										$property_of_radio = explode(': ',str_replace("***property***","",$element_value[1]));

										$property_of_radio = $property_of_radio[1];

									}

									

									$element_value	= explode(' :',$element_value[0]);

									$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

								}

								else

								{

									$quantity_value = explode(': ',str_replace("***quantity***","",$element_value[1]));

									$quantity_value = $quantity_value[1];

									$property_of_radio = explode(': ',str_replace("***property***","",$element_value[2]));

									$property_of_radio = $property_of_radio[1];

								

									$element_value	= explode(' :',$element_value[0]);

									$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

								}

							}

							else

							{

								$element_value	= explode(' :',$element_value);

								$choise_value = preg_replace("/[^0-9]/","",$element_value[1]);

								$quantity_value = '';

								$property_of_radio = '';

							}

							$total_queries = 0;

							foreach($param['w_choices'] as $key => $choice)

							{

								$key1 = $key + $total_queries;

								if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

								{

									$choices_labels =array();
									$choices_values =array();
									$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
									$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
									$w_choices_params = explode('[db_info]',$w_choices_params[1]);
									
									$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
									$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
				

									$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

									$table = $label_table_and_column[0];

									$label_column = $label_table_and_column[1];

									if($label_column)

									{

										$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);
									}	



									$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_price'][$key]));

									$value_column = $value_table_and_column[1];



									if($value_column)

									{

										$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

									}		



									$columns_count_radio = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

									

									if(array_filter($choices_labels) || array_filter($choices_values))

									{

										$total_queries = $total_queries + $columns_count_radio-1;

										for($k=0; $k<$columns_count_radio; $k++)

										{	

											$choice_label = isset($choices_labels) ? $choices_labels[$k] : '';

											$choice_value = isset($choices_values) ? (float)$choices_values[$k] : '';

					

											if($element_value[0] == $choice_label && $choice_value == $choise_value)

												$checked = 'checked="checked"';

											else

												$checked = '';

					

					

											$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'">'.$choice_label.'</label><div class="radio-div forlabs"><input type="radio" id="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$choice_value.'" title="'.htmlspecialchars($choice_label).'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'"></label></div></div>';

				

										}

									}			

								}

								else

								{

									if($element_value[0] == $choice && $param['w_choices_price'][$key] == $choise_value)

										$checked = 'checked="checked"';

									else

										$checked = '';

										

									$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.$key1.'">'.$choice.'</label><div class="radio-div forlabs"><input type="radio" id="wdform_'.$id1.'_element'.$form_id.''.$key1.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$param['w_choices_price'][$key].'" title="'.htmlspecialchars($choice).'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.$key1.'"></label></div></div>';

								}

							

							}



							$rep.='<div id="wdform_'.$id1.'_div'.$form_id.'">';

							if($param['w_quantity']=="yes")

								$rep.='<div class="paypal-property"><label class="mini_label" style="margin: 0px 5px;">Quantity</label><input type="text" value="'.($quantity_value=='' ? 1 : $quantity_value).'" id="wdform_'.$id1.'_element_quantity'.$form_id.'" name="wdform_'.$id1.'_element_quantity'.$form_id.'" class="wdform-quantity"></div>';

								

							if($param['w_property'][0])					

							foreach($param['w_property'] as $key => $property)

							{



							$rep.='

							<div class="paypal-property">

							<div style="width:150px; display:inline-block;">

							<label class="mini_label" id="wdform_'.$id1.'_property_label_'.$form_id.''.$key.'" style="margin-right: 5px;">'.$property.'</label>

							<select id="wdform_'.$id1.'_property'.$form_id.''.$key.'" name="wdform_'.$id1.'_property'.$form_id.''.$key.'" style="width: 100%; margin: 2px 0px;">';

							$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);

							$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   

							foreach($param['w_property_values'][$key] as $subkey => $property_value)

							{

								$rep.='<option id="wdform_'.$id1.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'" '.($property_of_radio==$property_value ? 'selected="selected"' : "").'>'.$property_value.'</option>';

							}

							$rep.='</select></div></div>';

							}

							

							$rep.='</div></div></div>';

								

						

							$onsubmit_js.='

								jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_label'.$form_id.'\" />").val(

								jQuery("label[for=\'"+jQuery("input[name^=\'wdform_'.$id1.'_element'.$form_id.'\']:checked").prop("id")+"\']").eq(0).text()

								).appendTo("#adminForm");



								';

							$onsubmit_js.='

								jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_quantity_label'.$form_id.'\"  />").val("Quantity").appendTo("#adminForm");

										';

							$onsubmit_js.='

								jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_property_label'.$form_id.'\"  />").val("'.$param['w_property'][0].'").appendTo("#adminForm");

										';	

						break;

					}
            

            case 'type_paypal_shipping':

					{

					

						if($element_value=='')

							$element_value =' - ';

		

							$params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');

							$temp=$params;



							if(strpos($temp, 'w_field_option_pos') > -1)

							$params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_choices_params', 'w_class');

							foreach($params_names as $params_name )

							{	

								$temp=explode('*:*'.$params_name.'*:*',$temp); 

								$param[$params_name] = $temp[0];

								$temp=$temp[1];

							}

							

							if($temp)

							{	

								$temp	=explode('*:*w_attr_name*:*',$temp);

								$attrs	= array_slice($temp,0, count($temp)-1);   

								foreach($attrs as $attr)

									$param['attributes'] = $param['attributes'].' '.$attr;

							}

							

							if(!isset($param['w_field_option_pos']))

								$param['w_field_option_pos'] = 'left';

								

							$param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");

							$param['w_field_option_pos1'] = ($param['w_field_option_pos']=="right" ? "style='float: none !important;'" : "");

							$param['w_field_option_pos2'] = ($param['w_field_option_pos']=="right" ? "style='float: left !important; margin-right: 8px !important; display: inline-block !important;'" : "");

							

							

							$param['w_choices']	= explode('***',$param['w_choices']);

							$param['w_choices_price']	= explode('***',$param['w_choices_price']);

							if(isset($param['w_choices_params']))

								$param['w_choices_params'] = explode('***',$param['w_choices_params']);	

						

							

							

							$element_value	= explode(' - ',$element_value);

							$element_value[1] = preg_replace("/[^0-9]/","",$element_value[1]);

								

							$rep='<div type="type_paypal_shipping" class="wdform-field"><div class="wdform-label-section" style="'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';

						

							$rep.='</div><div class="wdform-element-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].';">';

							

							$total_queries = 0;

							foreach($param['w_choices'] as $key => $choice)

							{

								$key1 = $key + $total_queries;

								if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])

								{			

									$choices_labels =array();
									$choices_values =array();
									$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
									$where = (str_replace(array('[',']'), '', $w_choices_params[0]) ? ' WHERE '.str_replace(array('[',']'), '', $w_choices_params[0]) : '');
									$w_choices_params = explode('[db_info]',$w_choices_params[1]);
									
									$order_by = str_replace(array('[',']'), '', $w_choices_params[0]);
									$db_info = str_replace(array('[',']'), '', $w_choices_params[1]);
				
									
									$label_table_and_column = explode(':',str_replace(array('[',']'), '', $choice));

									$table = $label_table_and_column[0];

									$label_column = $label_table_and_column[1];

									if($label_column)

									{

										$choices_labels = $this->model->select_data_from_db_for_labels($db_info, $label_column, $table, $where, $order_by);
									}	



									$value_table_and_column = explode(':',str_replace(array('[',']'), '', $param['w_choices_price'][$key]));

									$value_column = $value_table_and_column[1];



									if($value_column)

									{

										$choices_values = $this->model->select_data_from_db_for_values($db_info, $value_column, $table, $where, $order_by);

									}		



									$columns_count_shipping = count($choices_labels)>0 ?  count($choices_labels) : count($choices_values);

									

									if(array_filter($choices_labels) || array_filter($choices_values))

									{

										$total_queries = $total_queries + $columns_count_shipping-1;

										for($k=0; $k<$columns_count_shipping; $k++)

										{

											$choice_label = isset($choices_labels) ? $choices_labels[$k] : '';

											$choice_value = isset($choices_values) ? (float)$choices_values[$k] : '';

						

											$checked =(($choice_label==$element_value[0] && $choice_value== $element_value[1]) ? 'checked="checked"' : '');



											$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'">'.$choice_label.'</label><div class="radio-div forlabs"><input type="radio" id="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$choice_value.'" title="'.htmlspecialchars($choice_label).'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.($key1+$k).'"></label></div></div>';

										}	

									}	

								}

								else

								{

									$checked =(($choice==$element_value[0] && $param['w_choices_price'][$key]== $element_value[1]) ? 'checked="checked"' : '');

									

									$rep.='<div style="display: '.($param['w_flow']=='hor' ? 'inline-block' : 'table-row' ).';"><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.''.$key1.'">'.$choice.'</label><div class="radio-div forlabs"><input type="radio" id="wdform_'.$id1.'_element'.$form_id.''.$key1.'" name="wdform_'.$id1.'_element'.$form_id.'" value="'.$param['w_choices_price'][$key].'" title="'.htmlspecialchars($choice).'" '.$checked.' '.$param['attributes'].'><label for="wdform_'.$id1.'_element'.$form_id.''.$key1.'"></label></div></div>';

								}

							}



							$rep.='</div></div>';



						

							$onsubmit_js.='

								jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_element_label'.$form_id.'\" />").val(

								jQuery("label[for=\'"+jQuery("input[name^=\'wdform_'.$id1.'_element'.$form_id.'\']:checked").prop("id")+"\']").eq(0).text()

								).appendTo("#adminForm");



								';

				

						break;

					}
            
            case 'type_star_rating': { 					
              if($element_value=='')
                $element_value = '/'; 
                
                $params_names = array('w_field_label_size','w_field_label_pos','w_field_label_col','w_star_amount','w_required','w_class');
                $temp = $params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                          $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                $element_value = explode('/', $element_value);
        
                $images = '';	
                for($i=0; $i<$element_value[1]; $i++) {
                  $images .= '<img id="wdform_'.$id1.'_star_'.$i.'_'.$form_id.'" src="' . WD_FMC_URL . '/images/star.png" >';
                  
                  $onload_js .='jQuery("#wdform_'.$id1.'_star_'.$i.'_'.$form_id.'").mouseover(function() {change_src('.$i.',"wdform_'.$id1.'", "'.$form_id.'", "'.$param['w_field_label_col'].'");});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_star_'.$i.'_'.$form_id.'").mouseout(function() {reset_src('.$i.',"wdform_'.$id1.'", "'.$form_id.'");});';
                  $onload_js .='jQuery("#wdform_'.$id1.'_star_'.$i.'_'.$form_id.'").click(function() {select_star_rating('.$i.',"wdform_'.$id1.'", "'.$form_id.'","'.$param['w_field_label_col'].'", "'.$element_value[1].'");});';
                  $onload_js .='select_star_rating('.($element_value[0]-1).',"wdform_'.$id1.'", "'.$form_id.'","'.$param['w_field_label_col'].'", "'.$element_value[1].'");';
                }
                
                $rep ='<div type="type_star_rating" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><div id="wdform_'.$id1.'_element'.$form_id.'" '.$param['attributes'].'>'.$images.'</div><input type="hidden" value="" id="wdform_'.$id1.'_selected_star_amount'.$form_id.'" name="wdform_'.$id1.'_selected_star_amount'.$form_id.'"></div></div>';
                
            
                $onsubmit_js.='
                jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_star_amount'.$form_id.'\" value = \"'.$param['w_star_amount'].'\" />").appendTo("#form'.$form_id.'");
                ';

              break;
            }
            case 'type_scale_rating': {
            
              if($element_value=='')
                $element_value = '/';
                
                $params_names=array('w_field_label_size','w_field_label_pos','w_mini_labels','w_scale_amount','w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                          $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                $element_value = explode('/',$element_value);
                $w_mini_labels = explode('***',$param['w_mini_labels']);
                
                $numbers = '';	
                $radio_buttons = '';	
                $to_check=0;
                $to_check=$element_value[0];

                for($i=1; $i<=$element_value[1]; $i++) {
                  $numbers.= '<div  style="text-align: center; display: table-cell;"><span>'.$i.'</span></div>';
                  $radio_buttons.= '<div style="text-align: center; display: table-cell;"><div class="radio-div"><input id="wdform_'.$id1.'_scale_radio'.$form_id.'_'.$i.'" name="wdform_'.$id1.'_scale_radio'.$form_id.'" value="'.$i.'" type="radio" '.( $to_check==$i ? 'checked="checked"' : '' ).'><label for="wdform_'.$id1.'_scale_radio'.$form_id.'_'.$i.'"></label></div></div>';
                }
        
                $rep ='<div type="type_scale_rating" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                 
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><div id="wdform_'.$id1.'_element'.$form_id.'" style="float: left;" '.$param['attributes'].'><label class="mini_label">'.$w_mini_labels[0].'</label><div  style="display: inline-table; vertical-align: middle;border-spacing: 7px;"><div style="display: table-row;">'.$numbers.'</div><div style="display: table-row;">'.$radio_buttons.'</div></div><label class="mini_label" >'.$w_mini_labels[1].'</label></div></div></div>';
                 
                $onsubmit_js.='
                jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_scale_amount'.$form_id.'\" value = \"'.$param['w_scale_amount'].'\" />").appendTo("#form'.$form_id.'");
                ';
              
                break;
            }
            
            case 'type_spinner': {
              
                $params_names=array('w_field_label_size','w_field_label_pos','w_field_width','w_field_min_value','w_field_max_value', 'w_field_step', 'w_field_value', 'w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                          $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                
                $rep ='<div type="type_spinner" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
              
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><input type="text" value="'.($element_value!= 'null' ? $element_value : '').'" name="wdform_'.$id1.'_element'.$form_id.'" id="wdform_'.$id1.'_element'.$form_id.'" style="width: '.$param['w_field_width'].'px;" '.$param['attributes'].'></div></div>';
                
                $onload_js .='
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'")[0].spin = null;
                  spinner = jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner();
                  spinner.spinner( "value", "'.($element_value!= 'null' ? $element_value : '').'");
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner({ min: "'.$param['w_field_min_value'].'"});    
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner({ max: "'.$param['w_field_max_value'].'"});
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner({ step: "'.$param['w_field_step'].'"});
                ';
              
              break;
            }
            
            case 'type_slider': {
            
                $params_names=array('w_field_label_size','w_field_label_pos','w_field_width','w_field_min_value','w_field_max_value', 'w_field_value', 'w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
                
                
                $rep ='<div type="type_slider" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                 
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><input type="hidden" value="'.$element_value.'" id="wdform_'.$id1.'_slider_value'.$form_id.'" name="wdform_'.$id1.'_slider_value'.$form_id.'"><div name="'.$id1.'_element'.$form_id.'" id="wdform_'.$id1.'_element'.$form_id.'" style="width: '.$param['w_field_width'].'px;" '.$param['attributes'].'"></div><div align="left" style="display: inline-block; width: 33.3%; text-align: left;"><span id="wdform_'.$id1.'_element_min'.$form_id.'" class="label">'.$param['w_field_min_value'].'</span></div><div align="right" style="display: inline-block; width: 33.3%; text-align: center;"><span id="wdform_'.$id1.'_element_value'.$form_id.'" class="label">'.$element_value.'</span></div><div align="right" style="display: inline-block; width: 33.3%; text-align: right;"><span id="wdform_'.$id1.'_element_max'.$form_id.'" class="label">'.$param['w_field_max_value'].'</span></div></div></div>';
                    
                    
                $onload_js .='
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'")[0].slide = null;
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").slider({
                    range: "min",
                    value: eval('.$element_value.'),
                    min: eval('.$param['w_field_min_value'].'),
                    max: eval('.$param['w_field_max_value'].'),
                    slide: function( event, ui ) {	
                    
                      jQuery("#wdform_'.$id1.'_element_value'.$form_id.'").html("" + ui.value)
                      jQuery("#wdform_'.$id1.'_slider_value'.$form_id.'").val("" + ui.value)

                    }
                    });
                ';
            
              break;
            }
            
            
            case 'type_range': {
            
              if($element_value=='')
                $element_value = '-';
                
                $params_names=array('w_field_label_size','w_field_label_pos','w_field_range_width','w_field_range_step','w_field_value1', 'w_field_value2', 'w_mini_labels', 'w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
                $element_value = explode('-',$element_value);
                
                $w_mini_labels = explode('***',$param['w_mini_labels']);
                
                $rep ='<div type="type_range" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
               
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><div style="display: table;"><div style="display: table-row;"><div valign="middle" align="left" style="display: table-cell;"><input type="text" value="'.($element_value[0]!= 'null' ? $element_value[0] : '').'" name="wdform_'.$id1.'_element'.$form_id.'0" id="wdform_'.$id1.'_element'.$form_id.'0" style="width: '.$param['w_field_range_width'].'px;"  '.$param['attributes'].'></div><div valign="middle" align="left" style="display: table-cell; padding-left: 4px;"><input type="text" value="'.($element_value[1]!= 'null' ? $element_value[1] : '').'" name="wdform_'.$id1.'_element'.$form_id.'1" id="wdform_'.$id1.'_element'.$form_id.'1" style="width: '.$param['w_field_range_width'].'px;" '.$param['attributes'].'></div></div><div style="display: table-row;"><div valign="top" align="left" style="display: table-cell;"><label class="mini_label" id="wdform_'.$id1.'_mini_label_from">'.$w_mini_labels[0].'</label></div><div valign="top" align="left" style="display: table-cell;"><label class="mini_label" id="wdform_'.$id1.'_mini_label_to">'.$w_mini_labels[1].'</label></div></div></div></div></div>';
                 
                $onload_js .='
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'0")[0].spin = null;
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'1")[0].spin = null;
                  
                  spinner0 = jQuery("#wdform_'.$id1.'_element'.$form_id.'0").spinner();
                  spinner0.spinner( "value", "'.($element_value[0]!= 'null' ? $element_value[0] : '').'");
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner({ step: '.$param['w_field_range_step'].'});
                  
                  spinner1 = jQuery("#wdform_'.$id1.'_element'.$form_id.'1").spinner();
                  spinner1.spinner( "value", "'.($element_value[1]!= 'null' ? $element_value[1] : '').'");
                  jQuery("#wdform_'.$id1.'_element'.$form_id.'").spinner({ step: '.$param['w_field_range_step'].'});
                ';
          
              break;
            }
            
            case 'type_grading': { 
                $params_names=array('w_field_label_size','w_field_label_pos', 'w_items', 'w_total', 'w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                          $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	
              
                
                $element_value = explode(':', $element_value);
                
                $w_items = explode('***',$param['w_items']);
                  
                $w_items_labels =implode(':',$w_items);
                
                $grading_items ='';
                
              
                for($i=0; $i<(count($element_value))/2-1; $i++) {
                  $value=$element_value[$i];

                  $grading_items .= '<div class="wdform_grading"><input type="text" id="wdform_'.$id1.'_element'.$form_id.'_'.$i.'" name="wdform_'.$id1.'_element'.$form_id.'_'.$i.'"  value="'.$value.'" '.$param['attributes'].'><label class="wdform-ch-rad-label" for="wdform_'.$id1.'_element'.$form_id.'_'.$i.'">'.$w_items[$i].'</label></div>';
                    
                }
                  
                $rep ='<div type="type_grading" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><input type="hidden" value="'.$param['w_total'].'" name="wdform_'.$id1.'_grading_total'.$form_id.'" id="wdform_'.$id1.'_grading_total'.$form_id.'"><div id="wdform_'.$id1.'_element'.$form_id.'">'.$grading_items.'<div id="wdform_'.$id1.'_element_total_div'.$form_id.'" class="grading_div">Total: <span id="wdform_'.$id1.'_sum_element'.$form_id.'">0</span>/<span id="wdform_'.$id1.'_total_element'.$form_id.'">'.$param['w_total'].'</span><span id="wdform_'.$id1.'_text_element'.$form_id.'"></span></div></div></div></div>';
                
                $onload_js.='
                jQuery("#wdform_'.$id1.'_element'.$form_id.' input").change(function() {sum_grading_values("wdform_'.$id1.'","'.$form_id.'");});';
                
                $onload_js.='
                jQuery("#wdform_'.$id1.'_element'.$form_id.' input").keyup(function() {sum_grading_values("wdform_'.$id1.'","'.$form_id.'");});';
              
                
                $onload_js.='
                sum_grading_values("wdform_'.$id1.'","'.$form_id.'");';
                
                $onsubmit_js.='
                jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_hidden_item'.$form_id.'\" value = \"'.$w_items_labels.':'.$param['w_total'].'\" />").appendTo("#form'.$form_id.'");
                ';
            
              break;
            }
            case 'type_matrix': {
            
                $params_names=array('w_field_label_size','w_field_label_pos', 'w_field_input_type', 'w_rows', 'w_columns', 'w_required','w_class');
                $temp=$params;
                foreach($params_names as $params_name ) {	
                  $temp=explode('*:*'.$params_name.'*:*',$temp);
                  $param[$params_name] = $temp[0];
                  $temp=$temp[1];
                }

                if($temp) {	
                  $temp	=explode('*:*w_attr_name*:*',$temp);
                  $attrs	= array_slice($temp,0, count($temp)-1);   
                  foreach($attrs as $attr)
                    $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
                
                $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "float: left;" : "display:block;");	 
                $w_rows = explode('***',$param['w_rows']);
                $w_columns = explode('***',$param['w_columns']); 
                $element_value = str_replace("******matrix***","",$element_value);
                $element_value = explode($param['w_field_input_type'].'***', $element_value);
                $element_value = explode('***', $element_value[1]); 
                $column_labels ='';
                
                for($i=1; $i<count($w_columns); $i++) {
                  $column_labels .= '<div><label class="wdform-ch-rad-label">'.$w_columns[$i].'</label></div>';
                }
                
                $rows_columns = ''; 
                $for_matrix =0; 
                for($i=1; $i<count($w_rows); $i++) {
                
                  $rows_columns .= '<div class="wdform-matrix-row'.($i%2).'"><div class="wdform-matrix-column"><label class="wdform-ch-rad-label" >'.$w_rows[$i].'</label></div>';
                  
                
                  for($k=1; $k<count($w_columns); $k++) {
                    $rows_columns .= '<div class="wdform-matrix-cell">';
                    if($param['w_field_input_type']=='radio') { 	
                      if (array_key_exists($i-1,$element_value))
                        $to_check=$element_value[$i-1];
                      else
                        $to_check= '' ;
                                      
                      $rows_columns .= '<div class="radio-div"><input id="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'"  type="radio" name="wdform_'.$id1.'_input_element'.$form_id.''.$i.'" value="'.$i.'_'.$k.'" '.($to_check==$i.'_'.$k ? 'checked="checked"' : '').'><label for="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'"></label></div>';
                     
                    }
                    else
                      if($param['w_field_input_type']=='checkbox') {
                        
                        if (array_key_exists($for_matrix,$element_value))
                          $to_check=$element_value[$for_matrix];
                        else
                          $to_check= '' ;
                            
                        $rows_columns .= '<div class="checkbox-div"><input id="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'" type="checkbox" name="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'" value="1" '.($to_check=="1" ? 'checked="checked"' : '').'><label for="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'"></label></div>';
                        
                        $for_matrix++;
                      }
                      else
                        if($param['w_field_input_type']=='text') {
                          $rows_columns .= '<input id="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'" type="text" name="wdform_'.$id1.'_input_element'.$form_id.''.$i.'_'.$k.'" value="'.(array_key_exists($for_matrix,$element_value) ? $element_value[$for_matrix] : '').'">';
                        
                          $for_matrix++;										
                        }	
                        else
                          if($param['w_field_input_type']=='select') {
                            $rows_columns .= '<select id="wdform_'.$id1.'_select_yes_no'.$form_id.''.$i.'_'.$k.'" name="wdform_'.$id1.'_select_yes_no'.$form_id.''.$i.'_'.$k.'" ><option value="" '.(array_key_exists($for_matrix,$element_value) ? ($element_value[$for_matrix]=="" ? "selected=\"selected\"": "") : '').'> </option><option value="yes" '.(array_key_exists($for_matrix,$element_value) ? ($element_value[$for_matrix]=="yes" ? "selected=\"selected\"": "") : '').'>Yes</option><option value="no" '.(array_key_exists($for_matrix,$element_value) ? ($element_value[$for_matrix]=="no" ? "selected=\"selected\"": "") : '').'>No</option></select>';
                            
                            $for_matrix++;	
                          }
                    $rows_columns.='</div>';
                  }
                    
                  $rows_columns .= '</div>';	
                }
                  
                $rep ='<div type="type_matrix" class="wdform-field"><div class="wdform-label-section '.$param['w_class'].'" style="'.$param['w_field_label_pos'].' width: '.$param['w_field_label_size'].'px;"><span class="wdform-label">'.$label.'</span>';
                 
                $rep.='</div><div class="wdform-element-section '.$param['w_class'].'"  style="'.$param['w_field_label_pos'].'"><div id="wdform_'.$id1.'_element'.$form_id.'" class="wdform-matrix-table" '.$param['attributes'].'><div style="display: table-row-group;"><div class="wdform-matrix-head"><div style="display: table-cell;"></div>'.$column_labels.'</div>'.$rows_columns.'</div></div></div></div>';
                
                $onsubmit_js.='
                  jQuery("<input type=\"hidden\" name=\"wdform_'.$id1.'_input_type'.$form_id.'\" value = \"'.$param['w_field_input_type'].'\" /><input type=\"hidden\" name=\"wdform_'.$id1.'_hidden_row'.$form_id.'\" value = \"'.$param['w_rows'].'\" /><input type=\"hidden\" name=\"wdform_'.$id1.'_hidden_column'.$form_id.'\" value = \"'.$param['w_columns'].'\" />").appendTo("#form'.$form_id.'");
                  ';		
              
              break;
            }
          }
          $form = str_replace('%'.$id1.' - '.$labels[$id1s_key].'%', $rep, $form);
        }
      }
      echo $form;
      ?>
      
	  </div>
	  <input type="hidden" name="option" value="com_formmaker"/>
      <input type="hidden" id="current_id" name="current_id" value="<?php echo $rows[0]->group_id; ?>" />
      <input type="hidden" name="form_id" value="<?php echo $rows[0]->form_id; ?>" />
      <input type="hidden" name="date" value="<?php echo $rows[0]->date; ?>" />
      <input type="hidden" name="ip" value="<?php echo $rows[0]->ip; ?>" />
      <input type="hidden" id="task" name="task" value="" />
      <input type="hidden" value="<?php echo WD_FMC_URL; ?>" id="form_plugins_url" />
      <script type="text/javascript">
        function  pressbutton() {
          <?php echo $onsubmit_js; ?>;
        }
        jQuery("div[type='type_number'] input, div[type='type_phone'] input, div[type='type_spinner'] input, div[type='type_range'] input, .wdform-quantity").keypress(function(evt) {
          return check_isnum(evt);
        });	
        jQuery("div[type='type_grading'] input").keypress(function() {
          return check_isnum_or_minus(event);
        });
        plugin_url = '<?php echo WD_FMC_URL; ?>';
        <?php
        if ($onload_js) {
          ?>
          jQuery(window).load(function () {
            <?php echo $onload_js; ?>;
          });
          <?php
        }
        ?> 
      </script>
    </form> 
    <?php
  }
}

?>
views/FMViewGenerete_xml_fmc.php000060400000007535152435511120012740 0ustar00<?php

class FMViewGenerete_xml_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;

  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function display() {
	$form_id = (int)$_REQUEST['form_id'];  
	$params = $this->model->get_data();
	$limitstart = (int)$_REQUEST['limitstart'];
	$send_header = (int)$_REQUEST['send_header'];
	$data = $params[0];
	$title = $params[1]; 
	define('PHP_TAB', "\t");
	
	$upload_dir = wp_upload_dir();
	$file_path = $upload_dir['basedir'] . '/form-maker'; 
	if (!is_dir($file_path)) { 
		mkdir($file_path, 0777); 
	} 
	$tempfile = $file_path.'/export'.$form_id.'.txt';
	if($limitstart == 0 && file_exists ($tempfile))
		unlink($tempfile);
	$output = fopen($tempfile, "a");
	if($limitstart == 0) {
		fwrite($output, '<?xml version="1.0" encoding="utf-8" ?>'.PHP_EOL);
		fwrite($output, '<form title="'.$title.'">'.PHP_EOL);
	}	
	
	foreach ($data as $key1 => $value1) {
		fwrite($output, PHP_TAB.'<submission id="'.$key1.'">'.PHP_EOL);
		foreach ($value1 as $key => $value) {
			fwrite($output, PHP_TAB.PHP_TAB.'<field title="'.$key.'">'.PHP_EOL);
			fwrite($output, PHP_TAB.PHP_TAB.PHP_TAB.'<![CDATA['.$value.']]>'.PHP_EOL);
			fwrite($output, PHP_TAB.PHP_TAB.'</field>'.PHP_EOL);
		}
		fwrite($output, PHP_TAB.'</submission>'.PHP_EOL);
	}
	
	if($send_header == 1){
		fwrite($output, '</form>');
		fclose($output);
		
		$txtfile = fopen($tempfile, "r");
		$txtfilecontent = fread($txtfile, filesize($tempfile));
		fclose($txtfile);
		$filename = $title . "_" . date('Ymd') . ".xml";
		header('Content-Encoding: Windows-1252');
		header('Content-type: text/xml; charset=utf-8');
		header("Content-Disposition: attachment; filename=\"$filename\"");
		
		echo $txtfilecontent;
		unlink($tempfile);
		die(); 
	} 
	
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}views/FMViewGenerete_csv_fmc.php000060400000007721152435511120012730 0ustar00<?php

class FMViewGenerete_csv_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $model;

  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct($model) {
    $this->model = $model;
  }
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function display() {
		$fmc_settings = get_option('fmc_settings');	
		$csv_delimiter = isset($fmc_settings['csv_delimiter']) ? $fmc_settings['csv_delimiter'] : ',';	
		$form_id = (int)$_REQUEST['form_id'];
		$params = $this->model->get_data();
		$limitstart = (int)$_REQUEST['limitstart'];
		$send_header = (int)$_REQUEST['send_header'];
		$data = $params[0];
		$title = $params[1]; 
		$is_paypal_info = $params[2];
		
		$all_keys = array();
		foreach ($data as $row) {
			$all_keys = array_merge($all_keys, $row);
		}

		$keys_array = array_keys($all_keys);
		foreach ($data as $key => $row) {
			foreach ($keys_array as $key1 => $value) {
				if(!array_key_exists ( $value , $row ))
					array_splice($row, $key1, 0, '');
			}
			$data[$key] = $row;
		}

		$upload_dir = wp_upload_dir();
		$file_path = $upload_dir['basedir'] . '/form-maker'; 
		if (!is_dir($file_path)) { 
			mkdir($file_path, 0777); 
		} 
		$tempfile = $file_path.'/export'.$form_id.'.txt';
		if($limitstart == 0 && file_exists ($tempfile))
			unlink($tempfile);
		
		$output = fopen($tempfile, "a");
		if($limitstart == 0) {
			fputcsv($output, str_replace('PAYPAL_', '', $keys_array), $csv_delimiter);
		}
		
		foreach ($data as $record) {
			fputcsv($output, $record, $csv_delimiter);
		}
		fclose($output);
		
		if($send_header == 1){
			$txtfile = fopen($tempfile, "r");
			$txtfilecontent = fread($txtfile, filesize($tempfile));
			fclose($txtfile);

			$filename = $title . "_" . date('Ymd') . ".csv";
			header('Content-Encoding: Windows-1252');
			header('Content-type: text/csv; charset=Windows-1252');
			header("Content-Disposition: attachment; filename=\"$filename\"");
			
			echo $txtfilecontent;
			unlink($tempfile);
			die(); 
		}

	}

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelGoptions_fmc.php000060400000004321152435511120012366 0ustar00<?php

class FMModelGoptions_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFrommapeditinpopup_fmc.php000060400000004335152435511120014453 0ustar00<?php

class FMModelFrommapeditinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelSubmissions_fmc.php000060400000072716152435511120013117 0ustar00<?php 
class FMModelSubmissions_fmc {
	////////////////////////////////////////////////////////////////////////////////////////
	// Events                                                                             //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constants                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Variables                                                                          //
	////////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////////////////////
	// Constructor & Destructor                                                           //
	////////////////////////////////////////////////////////////////////////////////////////
	public function __construct() {
	}
	////////////////////////////////////////////////////////////////////////////////////////
	// Public Methods                                                                     //
	////////////////////////////////////////////////////////////////////////////////////////
	public function blocked_ips() {
		global $wpdb;
		$ips = $wpdb->get_col('SELECT ip FROM ' . $wpdb->prefix . 'formmaker_blocked');
		return $ips;
	}

	public function get_form_titles() {
		global $wpdb;
		$query = "SELECT id, title FROM " . $wpdb->prefix . "formmaker WHERE `id` IN(" . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ") order by title";
		$forms = $wpdb->get_results($query);
		return $forms;
	}
  
	public function get_statistics($form_id) { 
		global $wpdb;
		$statistics = array();
		$query = $wpdb->prepare('SELECT count(distinct group_id) FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id ="%d"', $form_id);
		$statistics["total_entries"] = $wpdb->get_var($query);
		$query = $wpdb->prepare('SELECT `views` FROM ' . $wpdb->prefix . 'formmaker_views WHERE form_id="%d"', $form_id);
		$statistics["total_views"] = $wpdb->get_var($query);
		if ($statistics["total_views"]) {
			$statistics["conversion_rate"] = round((($statistics["total_entries"] / $statistics["total_views"]) * 100), 2) . '%';
		}
		else {
			$statistics["conversion_rate"] = '0%';
		}
		return $statistics;
	}
  
  public function get_labels_parameters($form_id) {
    global $wpdb;
    $labels = array();
    $labels_id = array();
    $sorted_labels_id = array();
    $label_names = array();
    $label_types = array();
    $sorted_label_types = array();
    $label_names_original = array();
    $labels_parameters = array();
    $join_query = array();
    $join_where = array();
    $rows_ord = array();
    $join = '';
    for ($i = 0; $i < 8; $i++) {
      array_push($labels_parameters, NULL);
    }
    $sorted_label_names = array();
    $sorted_label_names_original = array();
    $where_labels = array();
    $where2 = array();
	
	$pagination_clicked = (isset($_POST['pagination_clicked']) && $_POST['pagination_clicked'] == '1' ? '1' : '0');
	
	$order_by = ((isset($_POST['order_by']) && esc_html(stripslashes($_POST['order_by'])) != '') ? esc_html(stripslashes($_POST['order_by'])) : 'group_id');
    $asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
    $limit = ((isset($_POST['page_number'])) ? ((int) $_POST['page_number'] - 1) * 20 : 0);
    $lists['hide_label_list'] = ((isset($_POST['hide_label_list'])) ? esc_html(stripslashes($_POST['hide_label_list'])) : '');
    $lists['startdate'] = ((isset($_POST['startdate'])) ? esc_html(stripslashes($_POST['startdate'])) : '');
    $lists['enddate'] = ((isset($_POST['enddate'])) ? esc_html(stripslashes($_POST['enddate'])) : '');
    $lists['ip_search'] = ((isset($_POST['ip_search'])) ? esc_html(stripslashes($_POST['ip_search'])) : '');
	
	$lists['username_search'] = ((isset($_POST['username_search'])) ? esc_html(stripslashes($_POST['username_search'])) : '');
	$lists['useremail_search'] = ((isset($_POST['useremail_search'])) ? esc_html(stripslashes($_POST['useremail_search'])) : '');
	$lists['id_search'] = ((isset($_POST['id_search'])) ? esc_html(stripslashes($_POST['id_search'])) : '');
	
    if ($lists['ip_search']) {
      $where[] = 'ip LIKE "%' . $lists['ip_search'] . '%"';
    }
    if ($lists['startdate'] != '') {
      $where[] = " `date`>='" . $lists['startdate'] . " 00:00:00' ";
    }
    if ($lists['enddate'] != '') {
      $where[] = " `date`<='" . $lists['enddate'] . " 23:59:59' ";
    }
	
	
	if ($lists['username_search']) {
      	$where[] = 'user_id_wd IN (SELECT ID FROM ' . $wpdb->prefix . 'users WHERE display_name LIKE "%'.$lists['username_search'].'%")';
    }
	if ($lists['useremail_search']) {
      $where[] = 'user_id_wd IN (SELECT ID FROM ' . $wpdb->prefix . 'users WHERE user_email LIKE "%'.$lists['useremail_search'].'%")';
    }
	
	if ($lists['id_search']) {
      $where[] = 'group_id ='.$lists['id_search'];
    }
	
    $where[] = 'form_id=' . $form_id . '';
    $where = (count($where) ? ' ' . implode(' AND ', $where) : ''); 
    if ($order_by == 'group_id' or $order_by == 'date' or $order_by == 'ip') { 
      $orderby = ' ORDER BY ' . $order_by . ' ' . $asc_or_desc . '';
    }elseif($order_by == 'display_name' or $order_by == 'user_email'){
	  $orderby 	= ' ORDER BY (SELECT '.$order_by.' FROM ' . $wpdb->prefix . 'users WHERE ID=user_id_wd) '. $asc_or_desc .'';
	}
    else {
      $orderby = "";
    }
		if ($form_id) {
      for($i = 0; $i < 8; $i++) {
        array_pop($labels_parameters);
      }
      $query = "SELECT distinct element_label FROM " . $wpdb->prefix . "formmaker_submits WHERE ". $where;
      $results = $wpdb->get_results($query); 
      for ($i = 0; $i < count($results); $i++) {
        array_push($labels, $results[$i]->element_label);
		  }
      $form = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "formmaker WHERE id='%d'", $form_id));
      if (strpos($form->label_order, 'type_paypal_')) {
        $form->label_order = $form->label_order . "item_total#**id**#Item Total#**label**#type_paypal_payment_total#****#total#**id**#Total#**label**#type_paypal_payment_total#****#0#**id**#Payment Status#**label**#type_paypal_payment_status#****#";
      }

      $form_labels = explode('#****#', $form->label_order);
      $form_labels = array_slice($form_labels, 0, count($form_labels) - 1);
	 
      foreach ($form_labels as $key => $form_label) {
        $label_id = explode('#**id**#', $form_label);
        array_push($labels_id, $label_id[0]);
        $label_name_type = explode('#**label**#', $label_id[1]);
        array_push($label_names_original, $label_name_type[0]);
        $ptn = "/[^a-zA-Z0-9_]/";
        $rpltxt = "";
        $label_name = preg_replace($ptn, $rpltxt, $label_name_type[0]);
        array_push($label_names, $label_name);
        array_push($label_types, $label_name_type[1]);
      }
	
      foreach ($labels_id as $key => $label_id) {
        if (in_array($label_id, $labels)) {
          if (!in_array($label_id, $sorted_labels_id)) {
            array_push($sorted_labels_id, $label_id);
          }
          array_push($sorted_label_names, $label_names[$key]);
          array_push($sorted_label_types, $label_types[$key]);
          array_push($sorted_label_names_original, $label_names_original[$key]);
          if (isset($_POST[$form_id . '_' . $label_id . '_search'])) {
            $search_temp = esc_html($_POST[$form_id . '_' . $label_id . '_search']);
          } 
          else {
            $search_temp = '';
          }
          $search_temp = strtolower($search_temp);
          $lists[$form_id . '_' . $label_id . '_search'] = $search_temp;
          if ($search_temp) {
            $join_query[] = 'search';
            $join_where[] = array('label' => $label_id, 'search' => $search_temp);
          }
        }
      }
      if (strpos($order_by, "_field")) { 	  
        if (in_array(str_replace("_field", "", $order_by), $labels)) {
          $join_query[]	= 'sort';
          $join_where[]	= array('label'=>str_replace("_field", "", $order_by));
        }
      }
      $cols = 'group_id';
      if ($order_by == 'date' or $order_by == 'ip') {
        $cols = 'group_id, date, ip';
      }
      switch (count($join_query)) {
        case 0:
          $join = 'SELECT distinct group_id FROM ' . $wpdb->prefix . 'formmaker_submits WHERE '. $where;
          break;
        case 1:
          if ($join_query[0] == 'sort') {
            $join = 'SELECT group_id FROM ' . $wpdb->prefix . 'formmaker_submits WHERE ' . $where . ' AND element_label="' . $join_where[0]['label'] . '" ';
            $join_count	= 'SELECT count(group_id) FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id="' . $form_id . '" AND element_label="' . $join_where[0]['label'] . '" ';
            $orderby =	' ORDER BY `element_value` ' . $asc_or_desc;
          } 
          else {
            $join = 'SELECT group_id FROM ' . $wpdb->prefix . 'formmaker_submits WHERE element_label="' . $join_where[0]['label'] . '" AND  element_value LIKE "%' . $join_where[0]['search'] . '%" AND ' . $where;
          }
          break;			
        default:
          $join = 'SELECT t.group_id FROM (SELECT ' . $cols . '  FROM ' . $wpdb->prefix . 'formmaker_submits WHERE ' . $where . ' AND element_label="' . $join_where[0]['label'] . '" AND  element_value LIKE "%' . $join_where[0]['search'] . '%" ) as t ';
          for ($key = 1; $key < count($join_query); $key++) {
            if ($join_query[$key] == 'sort') {
              $join .= 'LEFT JOIN (SELECT group_id as group_id' . $key . ', element_value   FROM ' . $wpdb->prefix . 'formmaker_submits WHERE ' . $where . ' AND element_label="' . $join_where[$key]['label'] . '") as t' . $key . ' ON t' . $key . '.group_id' . $key . '=t.group_id ';
              $orderby = ' ORDER BY t' . $key . '.`element_value` ' . $asc_or_desc . '';
            }
            else {
              $join .= 'INNER JOIN (SELECT group_id as group_id' . $key . ' FROM ' . $wpdb->prefix . 'formmaker_submits WHERE '.$where.' AND element_label="' . $join_where[$key]['label'] . '" AND  element_value LIKE "%' . $join_where[$key]['search'] . '%" ) as t' . $key . ' ON t' . $key . '.group_id' . $key . '=t.group_id ';
            }
          }
          break;
      }			  	  
      $pos = strpos($join, 'SELECT t.group_id');
      if ($pos === FALSE) {
        $query = str_replace(array('SELECT group_id','SELECT distinct group_id'), array('SELECT count(distinct group_id)','SELECT count(distinct group_id)'), $join);
      }
      else {
        $query = str_replace('SELECT t.group_id', 'SELECT count(t.group_id)', $join);
      }
      $total = $wpdb->get_var($query);
	  
	  $query_sub_count = "SELECT count(distinct group_id) from ".$wpdb->prefix."formmaker_submits";
      $sub_count = (int)$wpdb->get_var($query_sub_count);

	  $limit1 = (int)$total < $sub_count && !$pagination_clicked ? 0 : $limit; 
	  
      $query = $join . ' ' . $orderby . ' limit ' . $limit1 . ', 20 ';
      $results = $wpdb->get_results($query);
      for ($i = 0; $i < count($results); $i++) {
        array_push($rows_ord, $results[$i]->group_id); 
      }
      $where2 = array();
      $where2[] = "group_id='0'";
      foreach ($rows_ord as $rows_ordd) { 
        $where2[] = "group_id='" . $rows_ordd . "'";
      }
      $where2 = (count($where2) ? ' WHERE ' . implode( ' OR ', $where2 ) . '' : '' );
      $query = 'SELECT * FROM ' . $wpdb->prefix . 'formmaker_submits ' . $where2;
      $rows = $wpdb->get_results($query);
      $group_ids = $rows_ord;
      $lists['total'] = $total;
      $lists['limit'] = (int) ($limit1 / 20 + 1);
      $where_choices = $where;
      array_push($labels_parameters, $sorted_labels_id);
      array_push($labels_parameters, $sorted_label_types);
      array_push($labels_parameters, $lists);
      array_push($labels_parameters, $sorted_label_names);
      array_push($labels_parameters, $sorted_label_names_original);
      array_push($labels_parameters, $rows);
      array_push($labels_parameters, $group_ids);
      array_push($labels_parameters, $where_choices);
    }
    return $labels_parameters;
  }

  public function get_type_address($sorted_label_type, $sorted_label_name_original) {
    if ($sorted_label_type == 'type_address') {
      switch ($sorted_label_name_original) {
        case 'Street Line':
          $field_title = __('Street Address', 'form_maker');
          break;
        case 'Street Line2':
          $field_title = __('Street Address Line 2', 'form_maker');
          break;
        case 'City':
          $field_title = __('City', 'form_maker');
          break;
          case 'State':
          $field_title = __('State / Province / Region', 'form_maker');
          break;
        case 'Postal':
          $field_title = __('Postal / Zip Code', 'form_maker');
          break;
        case 'Country':
          $field_title = __('Country', 'form_maker');
          break;
        default :
          $field_title = stripslashes($sorted_label_name_original);
          break;
      }
    }
	  else {
	    $field_title = stripslashes($sorted_label_name_original);
    }
    return $field_title;
  }

  public function hide_or_not($hide_strings,$hide_string) {
    if (strpos($hide_string,'@') === FALSE) {
      if (strpos($hide_strings, '@' . $hide_string . '@') === FALSE) {
        $style = '';
      }
      else {
        $style = 'style="display:none"';
      }
    }
    else {
      if (strpos($hide_strings, $hide_string) === FALSE) {
        $style = '';
      }
      else {
        $style = 'style="display:none"';
      }
    }
    return $style;
  }

  public function sort_group_ids($sorted_label_names_count, $group_ids) {
    $count_labe = $sorted_label_names_count;
    $group_id_s = array();
    $l = 0;
    if (count($group_ids) > 0 and $count_labe) {
      for ($i = 0; $i < count($group_ids); $i++) {
        if (!in_array($group_ids[$i], $group_id_s)) {
          array_push($group_id_s, $group_ids[$i]);
        }
      }
    }
    return $group_id_s;
  }

  public function array_for_group_id($group, $rows) {
    $i = $group;
    $count_rows = count($rows);
    $temp = array();
    for ($j = 0; $j < $count_rows; $j++) {
      $row = $rows[$j];
      if ($row->group_id == $i) {
        array_push($temp, $row);
      }
    }
    return $temp;
  }

  public function check_radio_type($sorted_label_type) {
    if ($sorted_label_type == "type_checkbox" || $sorted_label_type == "type_radio" || $sorted_label_type == "type_own_select" || $sorted_label_type == "type_country"  || $sorted_label_type == "type_paypal_select" || $sorted_label_type == "type_paypal_radio" || $sorted_label_type == "type_paypal_checkbox" || $sorted_label_type == "type_paypal_shipping") {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

	public function statistic_for_radio($where_choices, $sorted_label_id) { 
		global $wpdb;
		$choices_params = array();
		$query = "SELECT element_value FROM " . $wpdb->prefix . "formmaker_submits WHERE " . $where_choices . " AND element_label='" . $sorted_label_id . "'";
		$choices = $wpdb->get_results($query);
		$colors=array('#5FE2FF','#F9E89C');
		$choices_colors=array('#4EC0D9','#DDCC7F');
		$choices_labels = array();
		$choices_count = array();
		$all = count($choices);
		$unanswered = 0;
		foreach ($choices as $key => $choice) {
			if ($choice->element_value == '') {
				$unanswered++;
			}
			else {
				if (!in_array($choice->element_value, $choices_labels)) {
					array_push($choices_labels, $choice->element_value);
					array_push($choices_count, 0);
				}
				$choices_count[array_search($choice->element_value, $choices_labels)]++;
			}
		}
		array_multisort($choices_count, SORT_DESC, $choices_labels);
		array_push($choices_params, $choices_count);
		array_push($choices_params, $choices_labels);
		array_push($choices_params, $unanswered);
		array_push($choices_params, $all);
		array_push($choices_params, $colors);
		array_push($choices_params, $choices_colors);
		return $choices_params;
	}

  public function get_data_of_group_id($id) {
    global $wpdb;
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id=" . $id;
    $rows = $wpdb->get_results($query);
    $form = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "formmaker WHERE id=" . $rows[0]->form_id);
    $params = array();
    $label_id = array();
    $label_order_original = array();
    $label_type = array();
    $ispaypal = strpos($form->label_order, 'type_paypal_');
    if ($form->paypal_mode == 1) {
      if ($ispaypal) {
        $form->label_order = $form->label_order."0#**id**#Payment Status#**label**#type_paypal_payment_status#****#";
      }
    }
    $label_all = explode('#****#', $form->label_order);
    $label_all = array_slice($label_all, 0, count($label_all) - 1);
    foreach ($label_all as $key => $label_each) {
      $label_id_each = explode('#**id**#', $label_each);
      array_push($label_id, $label_id_each[0]);
      $label_oder_each = explode('#**label**#', $label_id_each[1]);
      array_push($label_order_original, $label_oder_each[0]);
      array_push($label_type, $label_oder_each[1]);
    }
    /*$theme_id = $wpdb->get_var("SELECT theme FROM " . $wpdb->prefix . "formmaker WHERE id='" . $form->id . "'");*/
    $css = $wpdb->get_var("SELECT css FROM " . $wpdb->prefix . "formmaker_themes");
    array_push($params, $rows);
    array_push($params, $label_id);
    array_push($params, $label_order_original);
    array_push($params, $label_type);
    array_push($params, $ispaypal);
    array_push($params, $form);
    array_push($params, $css);
    return $params;
  }

  public function check_type_for_edit_function($label_type) {
    if ($label_type != 'type_editor' and $label_type != 'type_submit_reset' and $label_type != 'type_map' and $label_type != 'type_mark_map' and $label_type != 'type_captcha' and $label_type != 'type_recaptcha' and $label_type != 'type_button') {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }

  public function check_for_submited_label($rows, $label_id) {
    foreach ($rows as $row) {
      if ($row->element_label == $label_id) {
        $element_value = $row->element_value;
        break;
      }
      else {
        $element_value = 'continue';
      }
    }
    return $element_value;
  }

  public function view_for_star_rating($element_value, $element_label) {
    $view_star_rating_array = array();
    $new_filename = str_replace("***star_rating***", '', $element_value);
    $stars = "";
    $new_filename=explode('***', $new_filename);
    for ($j = 0; $j < $new_filename[1]; $j++) {
      $stars .= '<img id="' . $element_label . '_star_' . $j . '" src="' . WD_FMC_URL . '/images/star_' . $new_filename[2] . '.png?ver='. get_option("wd_form_maker_version").'" /> ';
    }
    for ($k = $new_filename[1]; $k < $new_filename[0]; $k++) {
      $stars .= '<img id="' . $element_label . '_star_' . $k . '" src="' . WD_FMC_URL . '/images/star.png?ver='. get_option("wd_form_maker_version").'" /> ';
    }
    array_push($view_star_rating_array, $stars);
    return $view_star_rating_array;
  }

  public function view_for_grading($element_value) {
    $view_grading_array = array();
    $new_filename = str_replace("***grading***", '', $element_value);
    $grading = explode(":", $new_filename);
    $items_count = sizeof($grading) - 1;
    $items = "";
    $total = "";
    for ($k = 0; $k < $items_count / 2; $k++) {
      $items .= $grading[$items_count / 2 + $k] . ": " . $grading[$k] . "</br>";
      $total += $grading[$k];
    }
    $items .= "Total: " . $total;
    array_push($view_grading_array, $items);
    return $view_grading_array;
  }

  public function images_for_star_rating($element_value, $label_id) {
    $edit_stars = "";
    $star_rating_array = array();
    $element_value1 = str_replace("***star_rating***", '', $element_value);
    $stars_value = explode('***', $element_value1);
    for ($j = 0; $j < $stars_value[1]; $j++) {
      $edit_stars .= '<img id="'.$label_id.'_star_'.$j.'" onclick="edit_star_rating('.$j.','.$label_id.')" src="' . WD_FMC_URL . '/images/star_'.$stars_value[2].'.png?ver='. get_option("wd_form_maker_version").'" /> ';
    }
    for( $k=$stars_value[1];$k<$stars_value[0];$k++) {
      $edit_stars .= '<img id="'.$label_id.'_star_'.$k.'" onclick="edit_star_rating('.$k.','.$label_id.')" src="' . WD_FMC_URL . '/images/star.png?ver='. get_option("wd_form_maker_version").'" /> ';
    }
    array_push($star_rating_array, $edit_stars);
    array_push($star_rating_array, $stars_value);
    return $star_rating_array;
  }

  public function params_for_scale_rating($element_value, $label_id) {
    $scale_rating_array = array();
    $scale_radio = explode('/', $element_value);
    $scale_value = $scale_radio[0];
    $scale = '<table><tr>';
    for ($k = 1; $k <= $scale_radio[1]; $k++) {
      $scale .= '<td style="text-align:center"><span>' . $k . '</span></td>';
    }
    $scale .= '<tr></tr>';
    for ($l = 1; $l <= $scale_radio[1]; $l++) {
      if ($l == $scale_radio[0]) {
        $checked = "checked";
      }
      else {
        $checked = "";
      }
      $scale .= '<td><input type="radio" name = "'.$label_id.'_scale_rating_radio" id = "'.$label_id.'_scale_rating_radio_'.$l.'" value="'.$l.'" '.$checked.' onClick="edit_scale_rating(this.value,'.$label_id.')" /></td>';
    }	
    $scale .= '</tr></table>';
    array_push($scale_rating_array, $scale);
    array_push($scale_rating_array, $scale_radio);
    array_push($scale_rating_array, $checked);
    return $scale_rating_array;
  }

  public function params_for_type_range($element_value, $label_id) {
    $range_value = explode('-', $element_value);
    $range = '<input name="'.$label_id.'_element0"  id="'.$label_id.'_element0" type="text" value="'.$range_value[0].'" onChange="edit_range(this.value,'.$label_id.',0)" size="8"/> - <input name="'.$label_id.'_element1"  id="'.$label_id.'_element1" type="text" value="'.$range_value[1].'" onChange="edit_range(this.value,'.$label_id.',1)" size="8"/>';
    return $range;
  }

  public function params_for_type_grading($element_value, $label_id) {
    $type_grading_array = array();
    $element_value1 = str_replace("***grading***", '', $element_value);
    $garding_value = explode(':', $element_value1);
    $items_count = sizeof($garding_value) - 1;
    $garding = "";
    $sum = "";
    for ($k = 0; $k < $items_count/2; $k++) {
      $garding .= '<input name="'.$label_id.'_element'.$k.'"  id="'.$label_id.'_element'.$k.'" type="text" value="'.$garding_value[$k].'" onKeyUp="edit_grading('.$label_id.','.$items_count.')" size="5"/> '.$garding_value[$items_count/2+$k].'</br>';
      $sum += $garding_value[$k];
    }
    array_push($type_grading_array, $garding);
    array_push($type_grading_array, $garding_value);
    array_push($type_grading_array, $sum);
    array_push($type_grading_array, $items_count);
    array_push($type_grading_array, $element_value1);
    return $type_grading_array;
  }

  public function params_for_type_matrix($element_value, $label_id) {
    $type_matrix_array = array();	
    $new_filename = str_replace("***matrix***", '', $element_value);
    $matrix_value = explode('***', $new_filename);
    $matrix_value = array_slice($matrix_value, 0, count($matrix_value) - 1);
    $mat_rows = $matrix_value[0];
    $mat_columns = $matrix_value[$mat_rows + 1];
    $matrix = "<table>";
    $matrix .= '<tr><td></td>';
    for ($k = 1; $k <= $mat_columns; $k++) {
      $matrix .= '<td style="background-color:#BBBBBB; padding:5px; border:1px; ">'.$matrix_value[$mat_rows+1+$k].'</td>';
    }
    $matrix .= '</tr>';
    $aaa = Array();
    $var_checkbox = 1;
    $selected_value = "";
    $selected_value_yes = "";
    $selected_value_no = "";
    for ($k = 1; $k <= $mat_rows; $k++) {
      $matrix .= '<tr><td style="background-color:#BBBBBB; padding:5px; border:1px;">'.$matrix_value[$k].'</td>';
      if ($matrix_value[$mat_rows + $mat_columns + 2] == "radio") {
        if ($matrix_value[$mat_rows + $mat_columns + 2 + $k] == 0) {
          $checked = "";
          $aaa[1] = "";
        }
        else {
          $aaa = explode("_", $matrix_value[$mat_rows + $mat_columns + 2 + $k]);
        }
        for ($l = 1; $l <= $mat_columns; $l++) {
          if ($aaa[1] == $l) {
            $checked = 'checked';
          }
          else {
            $checked = "";
          }
          $index = "'" . $k . '_' . $l . "'";
          $matrix .= '<td style="text-align:center;"><input name="'.$label_id.'_input_elementform_id_temp'.$k.'"  id="'.$label_id.'_input_elementform_id_temp'.$k.'_'.$l.'" type="'.$matrix_value[$mat_rows+$mat_columns+2].'" '.$checked.' onClick="change_radio_values('.$index.','.$label_id.','.$mat_rows.','.$mat_columns.')"/></td>';
        }
      }
      else {
        if ($matrix_value[$mat_rows+$mat_columns+2] == "checkbox") {
          for ($l = 1; $l <= $mat_columns; $l++) {
            if ($matrix_value[$mat_rows + $mat_columns + 2 + $var_checkbox] == 1) {
              $checked = 'checked';
            }
            else {
              $checked = '';
            }
            $index = "'".$k.'_'.$l."'";
            $matrix .='<td style="text-align:center;"><input name="'.$label_id.'_input_elementform_id_temp'.$k.'_'.$l.'"  id="'.$label_id.'_input_elementform_id_temp'.$k.'_'.$l.'" type="'.$matrix_value[$mat_rows+$mat_columns+2].'" '.$checked.' onClick="change_checkbox_values('.$index.','.$label_id.','.$mat_rows.','.$mat_columns.')"/></td>';
            $var_checkbox++;
          }
        }
        else {
          if ($matrix_value[$mat_rows + $mat_columns + 2] == "text") {
            for ($l = 1; $l <= $mat_columns; $l++) {
              $text_value = $matrix_value[$mat_rows+$mat_columns+2+$var_checkbox];
              $index = "'".$k.'_'.$l."'";									
              $matrix .= '<td style="text-align:center;"><input name="'.$label_id.'_input_elementform_id_temp'.$k.'_'.$l.'"  id="'.$label_id.'_input_elementform_id_temp'.$k.'_'.$l.'" type="'.$matrix_value[$mat_rows+$mat_columns+2].'" value="'.$text_value.'" onKeyUp="change_text_values('.$index.','.$label_id.','.$mat_rows.','.$mat_columns.')"/></td>';
              $var_checkbox++;
            }
          }
          else {
            for ($l = 1; $l <= $mat_columns; $l++) {
              $selected_text = $matrix_value[$mat_rows+$mat_columns + 2 + $var_checkbox];
              if ($selected_text == 'yes') {
                $selected_value_yes = 'selected';
                $selected_value_no = '';
                $selected_value = '';
              }
              else {
                if ($selected_text=='no') {
                  $selected_value_yes ='';
                  $selected_value_no ='selected';
                  $selected_value ='';
                }
                else {
                  $selected_value_yes = '';
                  $selected_value_no ='';
                  $selected_value ='selected';
                }
              }
              $index = "'".$k.'_'.$l."'";
              $matrix .= '<td style="text-align:center;"><select name="'.$label_id.'_select_yes_noform_id_temp'.$k.'_'.$l.'"  id="'.$label_id.'_select_yes_noform_id_temp'.$k.'_'.$l.'" onChange="change_option_values('.$index.','.$label_id.','.$mat_rows.','.$mat_columns.')"><option value="" '.$selected_value.'></option><option value="yes" '.$selected_value_yes.' >Yes</option><option value="no" '.$selected_value_no.'>No</option></select></td>';
              $var_checkbox++;
            }
          }
        }
      }
      $matrix .= '</tr>';
    }
    $matrix .= '</table>';
    array_push($type_matrix_array, $matrix);
    array_push($type_matrix_array, $new_filename);
    return $type_matrix_array;
  }
  
  public function select_data_from_db_for_labels($db_info,$label_column, $table, $where, $order_by) {
    global $wpdb;
        
		$query = "SELECT `" . $label_column . "` FROM " . $table . $where . " ORDER BY " . $order_by;
		if($db_info) { 
      $temp		= explode('@@@wdfhostwdf@@@',$db_info);
      $host		= $temp[0];
      $temp		= explode('@@@wdfportwdf@@@',$temp[1]);
      $port		= $temp[0];
      $temp		= explode('@@@wdfusernamewdf@@@',$temp[1]);
      $username	= $temp[0];
      $temp		= explode('@@@wdfpasswordwdf@@@',$temp[1]);
      $password	= $temp[0];
      $temp		= explode('@@@wdfdatabasewdf@@@',$temp[1]);
      $database	= $temp[0];
       
      $wpdb_temp = new wpdb($username, $password, $database, $host);
      $choices_labels = $wpdb_temp->get_col($query);				
    }
		else {
      $choices_labels = $wpdb->get_col($query);
    }
    return $choices_labels;
  }
  public function select_data_from_db_for_values($db_info,$value_column, $table, $where, $order_by) {
    global $wpdb;		  
		$query = "SELECT `" . $value_column . "` FROM " . $table . $where . " ORDER BY " . $order_by;
		if($db_info) {
      $temp		= explode('@@@wdfhostwdf@@@',$db_info);
      $host		= $temp[0];
      $temp		= explode('@@@wdfportwdf@@@',$temp[1]);
      $port		= $temp[0];
      $temp		= explode('@@@wdfusernamewdf@@@',$temp[1]);
      $username	= $temp[0];
      $temp		= explode('@@@wdfpasswordwdf@@@',$temp[1]);
      $password	= $temp[0];
      $temp		= explode('@@@wdfdatabasewdf@@@',$temp[1]);
      $database	= $temp[0];
       
      $wpdb_temp = new wpdb($username, $password, $database, $host);
      $choices_values = $wpdb_temp->get_col($query);				
    }
		else {
      $choices_values = $wpdb->get_col($query);
    }
    return $choices_values; 
  }
  public function get_subs_count($form_id) { 
    global $wpdb;
	$query = $wpdb->prepare("SELECT distinct group_id FROM " . $wpdb->prefix . "formmaker_submits where form_id=%d", $form_id);		
	$group_id_s = $wpdb->get_col($query);	
    return count($group_id_s);
  }
}

?>
models/FMModelFormcontactwindow.php000060400000004673152435511120013460 0ustar00<?php

class FMModelFormcontactwindow {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function get_form_data() {
    global $wpdb;
	$row = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "formmaker WHERE `id` IN(" . get_option('contact_form_forms', 0) . ") order by `title`");
    return $row;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelThemes_fmc.php000060400000010762152435511120012017 0ustar00<?php

class FMModelThemes_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function get_rows_data() {
    global $wpdb;
    $where = ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE title LIKE "%' . esc_html($_POST['search_value']) . '%"' : '');
    $asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
	$order_by_array = array('id', 'title', 'default');
    $order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
    $order_by = ' ORDER BY `' . $order_by . '` ' . $asc_or_desc;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker_themes " . $where . $order_by . " LIMIT " . $limit . ",20";
    $rows = $wpdb->get_results($query);
    return $rows;
  }
  
  public function get_row_data($id, $reset) {
    global $wpdb;
    if ($id != 0) {
      $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $id));
      if ($reset) {
        if (!$row->default) {
          $row_id = $row->id;
          $row_title = $row->title;
          $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker_themes WHERE default="%d"', 1));
          $row->id = $row_id;
          $row->title = $row_title;
          $row->default = FALSE;
        }
        else {
          $row->css = '';
        }
      }
    }
    else {
      $row = new stdClass();
      $row->id = 0;
      $row->title = '';
      $row->css = '';
      $row->default = 0;
    }
    return $row;
  }
  
  public function page_nav() {
    global $wpdb;
    $where = ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE title LIKE "%' . esc_html($_POST['search_value']) . '%"'  : '');
    $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker_themes " . $where;
    $total = $wpdb->get_var($query);
    $page_nav['total'] = $total;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $page_nav['limit'] = (int) ($limit / 20 + 1);
    return $page_nav;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFormMakerPreview_fmc.php000060400000005155152435511120014017 0ustar00<?php

class FMModelFormMakerPreview_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function get_theme_css($id) {
    global $wpdb;
    $css = $wpdb->get_var($wpdb->prepare('SELECT css FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $id));
    return $css;
  }

  public function get_form($form_id) {
    global $wpdb;
    $form = $wpdb->get_var($wpdb->prepare('SELECT form_front FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $form_id));
    return $form;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFromipinfoinpopup_fmc.php000060400000004334152435511120014313 0ustar00<?php

class FMModelFromipinfoinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelWidget_fmc.php000060400000005041152435511120012007 0ustar00<?php

class FMModelWidget_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function get_gallery_rows_data() {
    global $wpdb;
	$where = 'WHERE `id` IN (' . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ')';
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker ".$where." order by `title` ";
    $rows = $wpdb->get_results($query);
    return $rows;
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelManage_fmc.php000060400000620235152435511120011764 0ustar00<?php

class FMModelManage_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function get_rows_data() {
    global $wpdb;
	$where = 'WHERE `id` IN (' . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ')';
    $where .= ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE title LIKE "%' . esc_html($_POST['search_value']) . '%"' : '');
    $asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
	$order_by_array = array('id', 'title', 'mail');
	$order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
    $order_by = ' ORDER BY `' . $order_by . '` ' . $asc_or_desc;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker " . $where . $order_by . " LIMIT " . $limit . ",20";
    $rows = $wpdb->get_results($query);
    return $rows;
  }
  
  public function get_row_data($id) {
    global $wpdb;
    if ($id != 0) {
      $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $id));
    }
    else {
      $row = new stdClass();
      $row->id = 0;
      $row->title = '';
      $row->mail = '';
      $row->form = '';
      $row->form_front = '';
      $row->theme = 0;
      $row->javascript = '';
      $row->submit_text = '';
      $row->url = '';
      $row->submit_text_type = 0;
      $row->script1 = '';
      $row->script2 = '';
      $row->script_user1 = '';
      $row->script_user2 = '';
      $row->counter = 0;
      $row->label_order = '';
      $row->article_id = '';
      $row->pagination = '';
      $row->show_title = '';
      $row->show_numbers = '';
      $row->public_key = '';
      $row->private_key = '';
      $row->recaptcha_theme = '';
      $row->from_name = '';
      $row->from_mail = '';
      $row->label_order_current = '';
      $row->script_mail_user = '';
      $row->script_mail = '';
      $row->tax = 0;
      $row->payment_currency = '$';
      $row->paypal_email = '';
      $row->checkout_mode = 'testmode';
      $row->paypal_mode = 0;

      $row->published = 1;
      $row->form_fields = '';
      $row->savedb = 1;
      $row->sendemail = 1;
      $row->requiredmark = '*';
      $row->reply_to = 0;
      $row->send_to = 0;
      $row->autogen_layout = 1;
      $row->custom_front = '';
      $row->mail_from_user = '';
      $row->mail_from_name_user = '';
      $row->reply_to_user = '';
      $row->save_uploads = 1;
    }
    return $row;
  }

  public function get_row_data_new($id) {
    global $wpdb;
    if ($id != 0) {
      $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker_backup WHERE backup_id="%d"', $id));
      $labels2 = array();
      $label_id = array();
      $label_order_original = array(); 
      $label_type = array();
      $label_all = explode('#****#', $row->label_order);
      $label_all = array_slice($label_all, 0, count($label_all) - 1);
  		foreach($label_all as $key => $label_each) {
        $label_id_each=explode('#**id**#',$label_each);
        array_push($label_id, $label_id_each[0]);
        $label_oder_each=explode('#**label**#', $label_id_each[1]);
        array_push($label_order_original, addslashes($label_oder_each[0]));
        array_push($label_type, $label_oder_each[1]);
  		}
      $labels2['id'] = '"' . implode('","', $label_id) . '"';
      $labels2['label'] = '"' . implode('","', $label_order_original) . '"';
      $labels2['type'] = '"' . implode('","', $label_type) . '"';
      $ids = array();
      $types = array();
      $labels = array();
      $paramss = array();
      $fields = explode('*:*new_field*:*', $row->form_fields);
      $fields = array_slice($fields, 0, count($fields) - 1);   
      foreach ($fields as $field) {
        $temp=explode('*:*id*:*',$field);
        array_push($ids, $temp[0]);
        $temp=explode('*:*type*:*',$temp[1]);
        array_push($types, $temp[0]);
        $temp=explode('*:*w_field_label*:*',$temp[1]);
        array_push($labels, $temp[0]);
        array_push($paramss, $temp[1]);
      }
      $form = $row->form_front;
      foreach ($ids as $ids_key => $id) {
        $label = $labels[$ids_key];
        $type = $types[$ids_key];
        $params = $paramss[$ids_key];
        if (strpos($form, '%'.$id.' - '.$label.'%') || strpos($form, '%'.$id.' -'.$label.'%')) {
          $rep = '';
          $arrows='';
          $param = array();
          $param['attributes'] = '';
          switch($type)
          {
            case 'type_section_break':
            {
              $arrows =$arrows.'<div id="wdform_arrows'.$id.'" class="wdform_arrows" ><div id="X_'.$id.'" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/delete_el.png?ver='. get_option("wd_form_maker_version").'" title="Remove the field" onclick="remove_section_break(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;delete_el&quot;)" onmouseout="chnage_icons_src(this,&quot;delete_el&quot;)"></div><div id="edit_'.$id.'" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/edit.png?ver='. get_option("wd_form_maker_version").'" title="Edit the field" onclick="edit(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;edit&quot;)" onmouseout="chnage_icons_src(this,&quot;edit&quot;)"><span id="'.$id.'_element_labelform_id_temp" style="display: none;">custom_'.$id.'</span></div><div id="duplicate_'.$id.'" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/duplicate.png?ver='. get_option("wd_form_maker_version").'" title="Duplicate the field" onclick="duplicate(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;duplicate&quot;)" onmouseout="chnage_icons_src(this,&quot;duplicate&quot;)"></div></div>';
              break;
            }
            case 'type_editor':
            {
              $arrows =$arrows.'<div id="wdform_arrows'.$id.'" class="wdform_arrows" type="type_editor" style="margin-top:0px;"><div id="X_'.$id.'" valign="middle" align="right" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/delete_el.png?ver='. get_option("wd_form_maker_version").'" title="Remove the field" onclick="remove_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;delete_el&quot;)" onmouseout="chnage_icons_src(this,&quot;delete_el&quot;)"></div><div id="left_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/left.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the left" onclick="left_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;left&quot;)" onmouseout="chnage_icons_src(this,&quot;left&quot;)"></div><div id="up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field up" onclick="up_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;up&quot;)" onmouseout="chnage_icons_src(this,&quot;up&quot;)"></div><div id="down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field down" onclick="down_row(&quot;'.$id.'&quot;)"  onmouseover="chnage_icons_src(this,&quot;down&quot;)" onmouseout="chnage_icons_src(this,&quot;down&quot;)"></div><div id="right_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/right.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the right" onclick="right_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;right&quot;)" onmouseout="chnage_icons_src(this,&quot;right&quot;)"></div><div id="edit_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/edit.png?ver='. get_option("wd_form_maker_version").'" title="Edit the field" onclick="edit(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;edit&quot;)" onmouseout="chnage_icons_src(this,&quot;edit&quot;)"></div><div id="duplicate_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/duplicate.png?ver='. get_option("wd_form_maker_version").'" title="Duplicate the field" onclick="duplicate(&quot;'.$id.'&quot;)"  onmouseover="chnage_icons_src(this,&quot;duplicate&quot;)" onmouseout="chnage_icons_src(this,&quot;duplicate&quot;)"></div><div id="page_up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the upper page" onclick="page_up(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_up&quot;)" onmouseout="chnage_icons_src(this,&quot;page_up&quot;)"></div><div id="page_down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the lower page" onclick="page_down(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_down&quot;)" onmouseout="chnage_icons_src(this,&quot;page_down&quot;)"></div></div>';
              break;
            }
            
            case 'type_send_copy':
            case 'type_captcha':
			case 'type_arithmetic_captcha':
            case 'type_recaptcha':
            {
              $arrows =$arrows.'<div id="wdform_arrows'.$id.'" class="wdform_arrows"><div id="X_'.$id.'" valign="middle" align="right" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/delete_el.png?ver='. get_option("wd_form_maker_version").'" title="Remove the field" onclick="remove_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;delete_el&quot;)" onmouseout="chnage_icons_src(this,&quot;delete_el&quot;)"></div><div id="left_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/left.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the left" onclick="left_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;left&quot;)" onmouseout="chnage_icons_src(this,&quot;left&quot;)"></div><div id="up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field up" onclick="up_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;up&quot;)" onmouseout="chnage_icons_src(this,&quot;up&quot;)"></div><div id="down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field down" onclick="down_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;down&quot;)" onmouseout="chnage_icons_src(this,&quot;down&quot;)"></div><div id="right_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/right.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the right" onclick="right_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;right&quot;)" onmouseout="chnage_icons_src(this,&quot;right&quot;)"></div><div id="edit_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/edit.png?ver='. get_option("wd_form_maker_version").'" title="Edit the field" onclick="edit(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;edit&quot;)" onmouseout="chnage_icons_src(this,&quot;edit&quot;)"></div><div id="duplicate_'.$id.'" valign="middle" class="element_toolbar"></div><div id="page_up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the upper page" onclick="page_up(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_up&quot;)" onmouseout="chnage_icons_src(this,&quot;page_up&quot;)"></div><div id="page_down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the lower page" onclick="page_down(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_down&quot;)" onmouseout="chnage_icons_src(this,&quot;page_down&quot;)"></div></div>';
              break;
            }
            
            default :
            {
              $arrows =$arrows.'<div id="wdform_arrows'.$id.'" class="wdform_arrows" ><div id="X_'.$id.'" valign="middle" align="right" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/delete_el.png?ver='. get_option("wd_form_maker_version").'" title="Remove the field" onclick="remove_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;delete_el&quot;)" onmouseout="chnage_icons_src(this,&quot;delete_el&quot;)"></div><div id="left_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/left.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the left" onclick="left_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;left&quot;)" onmouseout="chnage_icons_src(this,&quot;left&quot;)"></div><div id="up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field up" onclick="up_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;up&quot;)" onmouseout="chnage_icons_src(this,&quot;up&quot;)"></div><div id="down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field down" onclick="down_row(&quot;'.$id.'&quot;)"  onmouseover="chnage_icons_src(this,&quot;down&quot;)" onmouseout="chnage_icons_src(this,&quot;down&quot;)"></div><div id="right_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/right.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the right" onclick="right_row(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;right&quot;)" onmouseout="chnage_icons_src(this,&quot;right&quot;)"></div><div id="edit_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/edit.png?ver='. get_option("wd_form_maker_version").'" title="Edit the field" onclick="edit(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;edit&quot;)" onmouseout="chnage_icons_src(this,&quot;edit&quot;)"></div><div id="duplicate_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/duplicate.png?ver='. get_option("wd_form_maker_version").'" title="Duplicate the field" onclick="duplicate(&quot;'.$id.'&quot;)"  onmouseover="chnage_icons_src(this,&quot;duplicate&quot;)" onmouseout="chnage_icons_src(this,&quot;duplicate&quot;)"></div><div id="page_up_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_up.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the upper page" onclick="page_up(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_up&quot;)" onmouseout="chnage_icons_src(this,&quot;page_up&quot;)"></div><div id="page_down_'.$id.'" valign="middle" class="element_toolbar"><img src="' . WD_FMC_URL . '/images/page_down.png?ver='. get_option("wd_form_maker_version").'" title="Move the field to the lower page" onclick="page_down(&quot;'.$id.'&quot;)" onmouseover="chnage_icons_src(this,&quot;page_down&quot;)" onmouseout="chnage_icons_src(this,&quot;page_down&quot;)"></div></div>';
              break;
            }
            
          }
          switch ($type) {
            case 'type_section_break': {
              $params_names = array('w_editor');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              $rep ='<div id="wdform_field'.$id.'" type="type_section_break" class="wdform_field_section_break">'.$arrows.'<span id="'.$id.'_element_labelform_id_temp" style="display: none;">custom_'.$id.'</span><div id="'.$id.'_element_sectionform_id_temp" align="left" class="wdform_section_break">'.$param['w_editor'].'</div></div><div id="'.$id.'_element_labelform_id_temp" style="color:red;">custom_'.$id.'</div>';
              break;
            }
            case 'type_editor': {
              $params_names = array('w_editor');
              $temp = $params;
              foreach ($params_names as $params_name ) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              $rep =$arrows.'<div id="wdform_field'.$id.'" type="type_editor" class="wdform_field" >'.$param['w_editor'].'</div><div id="'.$id.'_element_labelform_id_temp" style="color: red;">custom_'.$id.'</div>';
              break;
            }
            case 'type_send_copy': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_first_val', 'w_required');
              $temp = $params;
              foreach ($params_names as $params_name ) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {	
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");	
              $input_active = ($param['w_first_val'] == 'true' ? "checked='checked'" : "");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_send_copy" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" style="display: '.$param['w_field_label_pos'].'"><input type="hidden" value="type_send_copy" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp" /><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp" /><input type="checkbox" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" onclick="set_checked(&quot;'.$id.'&quot;,&quot;&quot;,&quot;form_id_temp&quot;)" '.$input_active.' '.$param['attributes'].' disabled /></div></div>';
              break;
            }
            case 'type_text': {
				$params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size', 'w_first_val', 'w_title', 'w_required', 'w_unique');
				$temp = $params;
				if(strpos($temp, 'w_regExp_status') > -1)
					$params_names = array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_required', 'w_regExp_status', 'w_regExp_value', 'w_regExp_common', 'w_regExp_arg', 'w_regExp_alert', 'w_unique');
				foreach ($params_names as $params_name) {
					$temp = explode('*:*' . $params_name . '*:*', $temp);
					$param[$params_name] = $temp[0];
					$temp = $temp[1];
				}
				if ($temp) {
					$temp	= explode('*:*w_attr_name*:*', $temp);
					$attrs = array_slice($temp, 0, count($temp) - 1);
					foreach ($attrs as $attr) {
					  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
					}
				}
				
				$param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
				$input_active = ($param['w_first_val'] == $param['w_title'] ? "input_deactive" : "input_active");
				$required_sym = ($param['w_required'] == "yes" ? " *" : "");
				
				$param['w_regExp_status'] = (isset($param['w_regExp_status']) ? $param['w_regExp_status'] : "no");
				$param['w_regExp_value'] = (isset($param['w_regExp_value']) ? $param['w_regExp_value'] : "");
				$param['w_regExp_common'] = (isset($param['w_regExp_common']) ? $param['w_regExp_common'] : "");
				$param['w_regExp_arg'] = (isset($param['w_regExp_arg']) ? $param['w_regExp_arg'] : "");
				$param['w_regExp_alert'] = (isset($param['w_regExp_alert']) ? $param['w_regExp_alert'] : "Incorrect Value");
				
				$rep ='<div id="wdform_field'.$id.'" type="type_text" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" style="display: '.$param['w_field_label_pos'].'"><input type="hidden" value="type_text" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp" /><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp" /><input type="hidden" value="'.$param['w_regExp_status'].'" name="'.$id.'_regExpStatusform_id_temp" id="'.$id.'_regExpStatusform_id_temp"><input type="hidden" value="'.$param['w_regExp_value'].'" name="'.$id.'_regExp_valueform_id_temp" id="'.$id.'_regExp_valueform_id_temp"><input type="hidden" value="'.$param['w_regExp_common'].'" name="'.$id.'_regExp_commonform_id_temp" id="'.$id.'_regExp_commonform_id_temp"><input type="hidden" value="'.$param['w_regExp_alert'].'" name="'.$id.'_regExp_alertform_id_temp" id="'.$id.'_regExp_alertform_id_temp"><input type="hidden" value="'.$param['w_regExp_arg'].'" name="'.$id.'_regArgumentform_id_temp" id="'.$id.'_regArgumentform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp" /><input type="text" class="'.$input_active.'" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" value="'.$param['w_first_val'].'" title="'.$param['w_title'].'" onfocus="delete_value(&quot;'.$id.'_elementform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_elementform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_elementform_id_temp&quot;)" style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div></div>';
				
				break;
            }
           case 'type_number': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size', 'w_first_val', 'w_title', 'w_required', 'w_unique', 'w_class');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);   
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $input_active = ($param['w_first_val'] == $param['w_title'] ? "input_deactive" : "input_active");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_number" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp"  class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'"><input type="hidden" value="type_number" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><input type="text" class="'.$input_active.'" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" value="'.$param['w_first_val'].'" title="'.$param['w_title'].'" onkeypress="return check_isnum(event)" onfocus="delete_value(&quot;'.$id.'_elementform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_elementform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_elementform_id_temp&quot;)" style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div></div>';
              break;
            }
            case 'type_password': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size', 'w_required', 'w_unique', 'w_class');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);   
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");	
              $rep ='<div id="wdform_field'.$id.'" type="type_password" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp"  class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'"><input type="hidden" value="type_password" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><input type="password" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div></div>';
              break;
            }
            case 'type_textarea': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size_w', 'w_size_h', 'w_first_val', 'w_title', 'w_required', 'w_unique', 'w_class');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $input_active = ($param['w_first_val'] == $param['w_title'] ? "input_deactive" : "input_active");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_textarea" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display:'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><input type="hidden" value="type_textarea" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><textarea class="'.$input_active.'" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" title="'.$param['w_title'].'"  onfocus="delete_value(&quot;'.$id.'_elementform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_elementform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_elementform_id_temp&quot;)" style="width: '.$param['w_size_w'].'px; height: '.$param['w_size_h'].'px;" '.$param['attributes'].' disabled>'.$param['w_first_val'].'</textarea></div></div>';
              break;
            }
            case 'type_phone': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size', 'w_first_val', 'w_title', 'w_mini_labels', 'w_required', 'w_unique', 'w_class');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $w_first_val = explode('***', $param['w_first_val']);
              $w_title = explode('***', $param['w_title']);
              $w_mini_labels = explode('***', $param['w_mini_labels']);
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $input_active = ($param['w_first_val'] == $param['w_title'] ? "input_deactive" : "input_active");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_phone" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_phone" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><div id="'.$id.'_table_name" style="display: table;"><div id="'.$id.'_tr_name1" style="display: table-row;"><div id="'.$id.'_td_name_input_first" style="display: table-cell;"><input type="text" class="'.$input_active.'" id="'.$id.'_element_firstform_id_temp" name="'.$id.'_element_firstform_id_temp" value="'.$w_first_val[0].'" title="'.$w_title[0].'" onfocus="delete_value(&quot;'.$id.'_element_firstform_id_temp&quot;)"onblur="return_value(&quot;'.$id.'_element_firstform_id_temp&quot;)"onchange="change_value(&quot;'.$id.'_element_firstform_id_temp&quot;)" onkeypress="return check_isnum(event)"style="width: 50px;" '.$param['attributes'].' disabled /><span class="wdform_line" style="margin: 0px 4px; padding: 0px;">-</span></div><div id="'.$id.'_td_name_input_last" style="display: table-cell;"><input type="text" class="'.$input_active.'" id="'.$id.'_element_lastform_id_temp" name="'.$id.'_element_lastform_id_temp" value="'.$w_first_val[1].'" title="'.$w_title[1].'" onfocus="delete_value(&quot;'.$id.'_element_lastform_id_temp&quot;)"onblur="return_value(&quot;'.$id.'_element_lastform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_element_lastform_id_temp&quot;)" onkeypress="return check_isnum(event)"style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div></div><div id="'.$id.'_tr_name2" style="display: table-row;"><div id="'.$id.'_td_name_label_first" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_area_code">'.$w_mini_labels[0].'</label></div><div id="'.$id.'_td_name_label_last" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_phone_number">'.$w_mini_labels[1].'</label></div></div></div></div></div>';
              break;
            }
            case 'type_name': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_first_val', 'w_title', 'w_mini_labels', 'w_size', 'w_name_format', 'w_required', 'w_unique', 'w_class');
              $temp = $params;
			  if(strpos($temp, 'w_name_fields') > -1)
				$params_names = array('w_field_label_size', 'w_field_label_pos', 'w_first_val', 'w_title', 'w_mini_labels', 'w_size', 'w_name_format', 'w_required', 'w_unique', 'w_class', 'w_name_fields');
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $w_first_val = explode('***', $param['w_first_val']);
              $w_title = explode('***', $param['w_title']);
              $w_mini_labels = explode('***', $param['w_mini_labels']);
			  
			  $param['w_name_fields'] =  isset($param['w_name_fields']) ? $param['w_name_fields'] : ($param['w_name_format'] == 'normal' ? 'no***no' : 'yes***yes');
			  $w_name_fields = explode('***', $param['w_name_fields']);

              $w_name_format = '<div id="'.$id.'_td_name_input_first" style="display: table-cell;"><input type="text" class="'.($w_first_val[0]==$w_title[0] ? "input_deactive" : "input_active").'" id="'.$id.'_element_firstform_id_temp" name="'.$id.'_element_firstform_id_temp" value="'.$w_first_val[0].'" title="'.$w_title[0].'" onfocus="delete_value(&quot;'.$id.'_element_firstform_id_temp&quot;)"onblur="return_value(&quot;'.$id.'_element_firstform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_element_firstform_id_temp&quot;)" style="margin-right: 10px; width: '.$param['w_size'].'px;"'.$param['attributes'].' disabled /></div><div id="'.$id.'_td_name_input_last" style="display: table-cell;"><input type="text" class="'.($w_first_val[1]==$w_title[1] ? "input_deactive" : "input_active").'" id="'.$id.'_element_lastform_id_temp" name="'.$id.'_element_lastform_id_temp" value="'.$w_first_val[1].'" title="'.$w_title[1].'" onfocus="delete_value(&quot;'.$id.'_element_lastform_id_temp&quot;)"onblur="return_value(&quot;'.$id.'_element_lastform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_element_lastform_id_temp&quot;)" style="margin-right: 10px; width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div>';
              $w_name_format_mini_labels = '<div id="'.$id.'_td_name_label_first" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_first">'.$w_mini_labels[1].'</label></div><div id="'.$id.'_td_name_label_last" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_last">'.$w_mini_labels[2].'</label></div>';
              
			  if($w_name_fields[0] == 'yes') {
				$w_name_format = '<div id="'.$id.'_td_name_input_title" style="display: table-cell;"><input type="text" class="'.($w_first_val[2]==$w_title[2] ? "input_deactive" : "input_active").'" id="'.$id.'_element_titleform_id_temp" name="'.$id.'_element_titleform_id_temp" value="'.$w_first_val[2].'" title="'.$w_title[2].'" onfocus="delete_value(&quot;'.$id.'_element_titleform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_element_titleform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_element_titleform_id_temp&quot;)" style="margin: 0px 10px 0px 0px; width: 40px;" disabled /></div>'.$w_name_format;
				$w_name_format_mini_labels ='<div id="'.$id.'_td_name_label_title" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_title">'.$w_mini_labels[0].'</label></div>'.$w_name_format_mini_labels;
			  }
			  
			  if($w_name_fields[1] == 'yes') {
				$w_name_format = $w_name_format.'<div id="'.$id.'_td_name_input_middle" style="display: table-cell;"><input type="text" class="'.($w_first_val[3]==$w_title[3] ? "input_deactive" : "input_active").'" id="'.$id.'_element_middleform_id_temp" name="'.$id.'_element_middleform_id_temp" value="'.$w_first_val[3].'" title="'.$w_title[3].'" onfocus="delete_value(&quot;'.$id.'_element_middleform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_element_middleform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_element_middleform_id_temp&quot;)" style="width: '.$param['w_size'].'px;" disabled /></div>';
				$w_name_format_mini_labels = $w_name_format_mini_labels.'<div id="'.$id.'_td_name_label_middle" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_middle">'.$w_mini_labels[3].'</label></div>';
			  }
			  
              $rep ='<div id="wdform_field'.$id.'" type="type_name" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_name" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><input type="hidden" name="'.$id.'_enable_fieldsform_id_temp" id="'.$id.'_enable_fieldsform_id_temp" title="'.$w_name_fields[0].'" first="yes" last="yes" middle="'.$w_name_fields[1].'"><div id="'.$id.'_table_name" cellpadding="0" cellspacing="0" style="display: table;"><div id="'.$id.'_tr_name1" style="display: table-row;">'.$w_name_format.'</div><div id="'.$id.'_tr_name2" style="display: table-row;">'.$w_name_format_mini_labels.'</div></div></div></div>';
              break;
            }
            case 'type_address': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_size', 'w_mini_labels', 'w_disabled_fields', 'w_required', 'w_class');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $w_mini_labels = explode('***', $param['w_mini_labels']);
              $w_disabled_fields = explode('***', $param['w_disabled_fields']);
              $hidden_inputs = '';
              $labels_for_id = array('street1', 'street2', 'city', 'state', 'postal', 'country');
              foreach ($w_disabled_fields as $key => $w_disabled_field) {
                if ($key != 6) {
                  if ($w_disabled_field == 'yes') {
                    $hidden_inputs .= '<input type="hidden" id="'.$id.'_'.$labels_for_id[$key].'form_id_temp" value="'.$w_mini_labels[$key].'" id_for_label="'.($id+$key).'">';
                  }
                }
              }
              $address_fields ='';
					$g=0;
					if($w_disabled_fields[0]=='no')
					{
					$g+=2;
					$address_fields .= '<span style="float: left; width: 100%; padding-bottom: 8px; display: block;"><input type="text" id="'.$id.'_street1form_id_temp" name="'.$id.'_street1form_id_temp" onchange="change_value(&quot;'.$id.'_street1form_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled /><label class="mini_label" id="'.$id.'_mini_label_street1" style="display: block;">'.$w_mini_labels[0].'</label></span>';
					}
					
					if($w_disabled_fields[1]=='no')
					{
					$g+=2;
					$address_fields .= '<span style="float: left; width: 100%; padding-bottom: 8px; display: block;"><input type="text" id="'.$id.'_street2form_id_temp" name="'.($id+1).'_street2form_id_temp" onchange="change_value(&quot;'.$id.'_street2form_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled /><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_street2">'.$w_mini_labels[1].'</label></span>';
					}
					
					if($w_disabled_fields[2]=='no')
					{
					$g++;
					$address_fields .= '<span style="float: left; width: 48%; padding-bottom: 8px;"><input type="text" id="'.$id.'_cityform_id_temp" name="'.($id+2).'_cityform_id_temp" onchange="change_value(&quot;'.$id.'_cityform_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled /><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_city">'.$w_mini_labels[2].'</label></span>';
					}
					
					if($w_disabled_fields[3]=='no')
					{
					$g++;
					if($w_disabled_fields[5]=='yes' && $w_disabled_fields[6]=='yes')
					$address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><select type="text" id="'.$id.'_stateform_id_temp" name="'.($id+3).'_stateform_id_temp" onchange="change_value(&quot;'.$id.'_stateform_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled ><option value=""></option><option value="Alabama">Alabama</option><option value="Alaska">Alaska</option><option value="Arizona">Arizona</option><option value="Arkansas">Arkansas</option><option value="California">California</option><option value="Colorado">Colorado</option><option value="Connecticut">Connecticut</option><option value="Delaware">Delaware</option><option value="Florida">Florida</option><option value="Georgia">Georgia</option><option value="Hawaii">Hawaii</option><option value="Idaho">Idaho</option><option value="Illinois">Illinois</option><option value="Indiana">Indiana</option><option value="Iowa">Iowa</option><option value="Kansas">Kansas</option><option value="Kentucky">Kentucky</option><option value="Louisiana">Louisiana</option><option value="Maine">Maine</option><option value="Maryland">Maryland</option><option value="Massachusetts">Massachusetts</option><option value="Michigan">Michigan</option><option value="Minnesota">Minnesota</option><option value="Mississippi">Mississippi</option><option value="Missouri">Missouri</option><option value="Montana">Montana</option><option value="Nebraska">Nebraska</option><option value="Nevada">Nevada</option><option value="New Hampshire">New Hampshire</option><option value="New Jersey">New Jersey</option><option value="New Mexico">New Mexico</option><option value="New York">New York</option><option value="North Carolina">North Carolina</option><option value="North Dakota">North Dakota</option><option value="Ohio">Ohio</option><option value="Oklahoma">Oklahoma</option><option value="Oregon">Oregon</option><option value="Pennsylvania">Pennsylvania</option><option value="Rhode Island">Rhode Island</option><option value="South Carolina">South Carolina</option><option value="South Dakota">South Dakota</option><option value="Tennessee">Tennessee</option><option value="Texas">Texas</option><option value="Utah">Utah</option><option value="Vermont">Vermont</option><option value="Virginia">Virginia</option><option value="Washington">Washington</option><option value="West Virginia">West Virginia</option><option value="Wisconsin">Wisconsin</option><option value="Wyoming">Wyoming</option></select><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_state">'.$w_mini_labels[3].'</label></span>';
					else
					$address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><input type="text" id="'.$id.'_stateform_id_temp" name="'.($id+3).'_stateform_id_temp" onchange="change_value(&quot;'.$id.'_stateform_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_state">'.$w_mini_labels[3].'</label></span>';
					}
					
					if($w_disabled_fields[4]=='no')
					{
					$g++;
					$address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><input type="text" id="'.$id.'_postalform_id_temp" name="'.($id+4).'_postalform_id_temp" onchange="change_value(&quot;'.$id.'_postalform_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_postal">'.$w_mini_labels[4].'</label></span>';
					}
					
					if($w_disabled_fields[5]=='no')
					{
					$g++;
					$address_fields .= '<span style="float: '.(($g%2==0) ? 'right' : 'left').'; width: 48%; padding-bottom: 8px;"><select type="text" id="'.$id.'_countryform_id_temp" name="'.($id+5).'_countryform_id_temp" onchange="change_value(&quot;'.$id.'_countryform_id_temp&quot;)" style="width: 100%;" '.$param['attributes'].' disabled><option value=""></option><option value="Afghanistan">Afghanistan</option><option value="Albania">Albania</option><option value="Algeria">Algeria</option><option value="Andorra">Andorra</option><option value="Angola">Angola</option><option value="Antigua and Barbuda">Antigua and Barbuda</option><option value="Argentina">Argentina</option><option value="Armenia">Armenia</option><option value="Australia">Australia</option><option value="Austria">Austria</option><option value="Azerbaijan">Azerbaijan</option><option value="Bahamas">Bahamas</option><option value="Bahrain">Bahrain</option><option value="Bangladesh">Bangladesh</option><option value="Barbados">Barbados</option><option value="Belarus">Belarus</option><option value="Belgium">Belgium</option><option value="Belize">Belize</option><option value="Benin">Benin</option><option value="Bhutan">Bhutan</option><option value="Bolivia">Bolivia</option><option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option><option value="Botswana">Botswana</option><option value="Brazil">Brazil</option><option value="Brunei">Brunei</option><option value="Bulgaria">Bulgaria</option><option value="Burkina Faso">Burkina Faso</option><option value="Burundi">Burundi</option><option value="Cambodia">Cambodia</option><option value="Cameroon">Cameroon</option><option value="Canada">Canada</option><option value="Cape Verde">Cape Verde</option><option value="Central African Republic">Central African Republic</option><option value="Chad">Chad</option><option value="Chile">Chile</option><option value="China">China</option><option value="Colombia">Colombia</option><option value="Comoros">Comoros</option><option value="Congo (Brazzaville)">Congo (Brazzaville)</option><option value="Congo">Congo</option><option value="Costa Rica">Costa Rica</option><option value="Cote d\'Ivoire">Cote d\'Ivoire</option><option value="Croatia">Croatia</option><option value="Cuba">Cuba</option><option value="Cyprus">Cyprus</option><option value="Czech Republic">Czech Republic</option><option value="Denmark">Denmark</option><option value="Djibouti">Djibouti</option><option value="Dominica">Dominica</option><option value="Dominican Republic">Dominican Republic</option><option value="East Timor (Timor Timur)">East Timor (Timor Timur)</option><option value="Ecuador">Ecuador</option><option value="Egypt">Egypt</option><option value="El Salvador">El Salvador</option><option value="Equatorial Guinea">Equatorial Guinea</option><option value="Eritrea">Eritrea</option><option value="Estonia">Estonia</option><option value="Ethiopia">Ethiopia</option><option value="Fiji">Fiji</option><option value="Finland">Finland</option><option value="France">France</option><option value="Gabon">Gabon</option><option value="Gambia, The">Gambia, The</option><option value="Georgia">Georgia</option><option value="Germany">Germany</option><option value="Ghana">Ghana</option><option value="Greece">Greece</option><option value="Grenada">Grenada</option><option value="Guatemala">Guatemala</option><option value="Guinea">Guinea</option><option value="Guinea-Bissau">Guinea-Bissau</option><option value="Guyana">Guyana</option><option value="Haiti">Haiti</option><option value="Honduras">Honduras</option><option value="Hungary">Hungary</option><option value="Iceland">Iceland</option><option value="India">India</option><option value="Indonesia">Indonesia</option><option value="Iran">Iran</option><option value="Iraq">Iraq</option><option value="Ireland">Ireland</option><option value="Israel">Israel</option><option value="Italy">Italy</option><option value="Jamaica">Jamaica</option><option value="Japan">Japan</option><option value="Jordan">Jordan</option><option value="Kazakhstan">Kazakhstan</option><option value="Kenya">Kenya</option><option value="Kiribati">Kiribati</option><option value="Korea, North">Korea, North</option><option value="Korea, South">Korea, South</option><option value="Kuwait">Kuwait</option><option value="Kyrgyzstan">Kyrgyzstan</option><option value="Laos">Laos</option><option value="Latvia">Latvia</option><option value="Lebanon">Lebanon</option><option value="Lesotho">Lesotho</option><option value="Liberia">Liberia</option><option value="Libya">Libya</option><option value="Liechtenstein">Liechtenstein</option><option value="Lithuania">Lithuania</option><option value="Luxembourg">Luxembourg</option><option value="Macedonia">Macedonia</option><option value="Madagascar">Madagascar</option><option value="Malawi">Malawi</option><option value="Malaysia">Malaysia</option><option value="Maldives">Maldives</option><option value="Mali">Mali</option><option value="Malta">Malta</option><option value="Marshall Islands">Marshall Islands</option><option value="Mauritania">Mauritania</option><option value="Mauritius">Mauritius</option><option value="Mexico">Mexico</option><option value="Micronesia">Micronesia</option><option value="Moldova">Moldova</option><option value="Monaco">Monaco</option><option value="Mongolia">Mongolia</option><option value="Morocco">Morocco</option><option value="Mozambique">Mozambique</option><option value="Myanmar">Myanmar</option><option value="Namibia">Namibia</option><option value="Nauru">Nauru</option><option value="Nepal">Nepal</option><option value="Netherlands">Netherlands</option><option value="New Zealand">New Zealand</option><option value="Nicaragua">Nicaragua</option><option value="Niger">Niger</option><option value="Nigeria">Nigeria</option><option value="Norway">Norway</option><option value="Oman">Oman</option><option value="Pakistan">Pakistan</option><option value="Palau">Palau</option><option value="Panama">Panama</option><option value="Papua New Guinea">Papua New Guinea</option><option value="Paraguay">Paraguay</option><option value="Peru">Peru</option><option value="Philippines">Philippines</option><option value="Poland">Poland</option><option value="Portugal">Portugal</option><option value="Qatar">Qatar</option><option value="Romania">Romania</option><option value="Russia">Russia</option><option value="Rwanda">Rwanda</option><option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option><option value="Saint Lucia">Saint Lucia</option><option value="Saint Vincent">Saint Vincent</option><option value="Samoa">Samoa</option><option value="San Marino">San Marino</option><option value="Sao Tome and Principe">Sao Tome and Principe</option><option value="Saudi Arabia">Saudi Arabia</option><option value="Senegal">Senegal</option><option value="Serbia and Montenegro">Serbia and Montenegro</option><option value="Seychelles">Seychelles</option><option value="Sierra Leone">Sierra Leone</option><option value="Singapore">Singapore</option><option value="Slovakia">Slovakia</option><option value="Slovenia">Slovenia</option><option value="Solomon Islands">Solomon Islands</option><option value="Somalia">Somalia</option><option value="South Africa">South Africa</option><option value="Spain">Spain</option><option value="Sri Lanka">Sri Lanka</option><option value="Sudan">Sudan</option><option value="Suriname">Suriname</option><option value="Swaziland">Swaziland</option><option value="Sweden">Sweden</option><option value="Switzerland">Switzerland</option><option value="Syria">Syria</option><option value="Taiwan">Taiwan</option><option value="Tajikistan">Tajikistan</option><option value="Tanzania">Tanzania</option><option value="Thailand">Thailand</option><option value="Togo">Togo</option><option value="Tonga">Tonga</option><option value="Trinidad and Tobago">Trinidad and Tobago</option><option value="Tunisia">Tunisia</option><option value="Turkey">Turkey</option><option value="Turkmenistan">Turkmenistan</option><option value="Tuvalu">Tuvalu</option><option value="Uganda">Uganda</option><option value="Ukraine">Ukraine</option><option value="United Arab Emirates">United Arab Emirates</option><option value="United Kingdom">United Kingdom</option><option value="United States">United States</option><option value="Uruguay">Uruguay</option><option value="Uzbekistan">Uzbekistan</option><option value="Vanuatu">Vanuatu</option><option value="Vatican City">Vatican City</option><option value="Venezuela">Venezuela</option><option value="Vietnam">Vietnam</option><option value="Yemen">Yemen</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option></select><label class="mini_label" style="display: block;" id="'.$id.'_mini_label_country">'.$w_mini_labels[5].'</span>';
					}				
				
					$rep ='<div id="wdform_field'.$id.'" type="type_address" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px; vertical-align:top;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_address" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" name="'.$id.'_disable_fieldsform_id_temp" id="'.$id.'_disable_fieldsform_id_temp" street1="'.$w_disabled_fields[0].'" street2="'.$w_disabled_fields[1].'" city="'.$w_disabled_fields[2].'" state="'.$w_disabled_fields[3].'" postal="'.$w_disabled_fields[4].'" country="'.$w_disabled_fields[5].'" us_states="'.$w_disabled_fields[6].'"><div id="'.$id.'_div_address" style="width: '.$param['w_size'].'px;">'.$address_fields.$hidden_inputs.'</div></div></div>';
					break;
            }
            case 'type_submitter_mail': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_first_val','w_title','w_required','w_unique', 'w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $input_active = ($param['w_first_val']==$param['w_title'] ? "input_deactive" : "input_active");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
            
              $rep ='<div id="wdform_field'.$id.'" type="type_submitter_mail" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_submitter_mail" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_unique'].'" name="'.$id.'_uniqueform_id_temp" id="'.$id.'_uniqueform_id_temp"><input type="text" class="'.$input_active.'" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" value="'.$param['w_first_val'].'" title="'.$param['w_title'].'" onfocus="delete_value(&quot;'.$id.'_elementform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_elementform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_elementform_id_temp&quot;)" style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled /></div></div>';
              break;
            }
            case 'type_checkbox':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');
              $temp=$params;
			  if(strpos($temp, 'w_field_option_pos') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos','w_field_option_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_value_disabled','w_choices_value', 'w_choices_params', 'w_class');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
               if(!isset($param['w_value_disabled']))
						$param['w_value_disabled'] = 'no';
					
			   if(!isset($param['w_field_option_pos']))
						$param['w_field_option_pos'] = 'left';
						
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
			  
              if(isset($param['w_choices_value']))
				{
					$param['w_choices_value'] = explode('***',$param['w_choices_value']);
					$param['w_choices_params'] = explode('***',$param['w_choices_params']);	
				}
					
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='checked="checked"';
                else
                  $param['w_choices_checked'][$key]='';
              }
              
              $rep='<div id="wdform_field'.$id.'" type="type_checkbox" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_checkbox" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_randomize'].'" name="'.$id.'_randomizeform_id_temp" id="'.$id.'_randomizeform_id_temp"><input type="hidden" value="'.$param['w_allow_other'].'" name="'.$id.'_allow_otherform_id_temp" id="'.$id.'_allow_otherform_id_temp"><input type="hidden" value="'.$param['w_allow_other_num'].'" name="'.$id.'_allow_other_numform_id_temp" id="'.$id.'_allow_other_numform_id_temp"><input type="hidden" value="'.$param['w_rowcol'].'" name="'.$id.'_rowcol_numform_id_temp" id="'.$id.'_rowcol_numform_id_temp"><input type="hidden" value="'.$param['w_field_option_pos'].'" id="'.$id.'_option_left_right"><input type="hidden" value="'.$param['w_value_disabled'].'" name="'.$id.'_value_disabledform_id_temp" id="'.$id.'_value_disabledform_id_temp"><div style="display: table;"><div id="'.$id.'_table_little" style="display: table-row-group;" '.($param['w_flow']=='hor' ? 'for_hor="'.$id.'_hor"' : '').'>';
				
            if($param['w_flow']=='hor')
            {
                $j = 0;
                for($i=0; $i<(int)$param['w_rowcol']; $i++)
                {
                  $rep.='<div id="'.$id.'_element_tr'.$i.'" style="display: table-row;">';
                  
                    for($l=0; $l<=(int)(count($param['w_choices'])/$param['w_rowcol']); $l++)
                    {
                      if($j >= count($param['w_choices'])%$param['w_rowcol'] && $l==(int)(count($param['w_choices'])/$param['w_rowcol']))
                      continue;
                      
                      if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$i+$l)
							         $rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$l+$i).'" idi="'.((int)$param['w_rowcol']*$l+$i).'" style="display: table-cell;"><input type="checkbox" value="" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" other="1" onclick="if(set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$l+$i).'&quot;,&quot;form_id_temp&quot;)) show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$l+$i].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled  /><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$l+$i).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'">'.$param['w_choices'][(int)$param['w_rowcol']*$l+$i].'</label></div>';
								else	
									{
										$where = '';
										$order_by = '';
										$db_info = '';
										if(isset($param['w_choices_value']))
											$choise_value = $param['w_choices_value'][(int)$param['w_rowcol']*$l+$i];
										else
											$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$l+$i];
									
										if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$l+$i])
										{
											$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$l+$i]);
											$where = "where='".$w_choices_params[0]."'";
											$w_choices_params = explode('[db_info]',$w_choices_params[1]);
											$order_by = "order_by='".$w_choices_params[0]."'";
											$db_info = "db_info='".$w_choices_params[1]."'";
										}
									
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$l+$i).'" idi="'.((int)$param['w_rowcol']*$l+$i).'" style="display: table-cell;"><input type="checkbox" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$l+$i).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$l+$i].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$l+$i).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$l+$i].'</label></div>';	
									}
                    }
                  
                  $j++;
                  $rep.='</div>';	
                  
                }
          
            }
            else
            {
                for($i=0; $i<(int)(count($param['w_choices'])/$param['w_rowcol']); $i++)
                {
                  $rep.='<div id="'.$id.'_element_tr'.$i.'" style="display: table-row;">';
							
							if(count($param['w_choices']) > (int)$param['w_rowcol'])
								for($l=0; $l<$param['w_rowcol']; $l++)
								{
									if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$i+$l)
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="checkbox" value="" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" other="1" onclick="if(set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)) show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled /><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'">'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
										else
									{
										$where = '' ;
										$order_by = '' ;
										$db_info = '' ;
										if(isset($param['w_choices_value']))
											$choise_value =	$param['w_choices_value'][(int)$param['w_rowcol']*$i+$l]; 
										else
											$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$i+$l];

										if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$i+$l])
										{
											$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$i+$l]);
											$where = "where='".$w_choices_params[0]."'";
											$w_choices_params = explode('[db_info]',$w_choices_params[1]);
											$order_by = "order_by='".$w_choices_params[0]."'";
											$db_info = "db_info='".$w_choices_params[1]."'";
										}
									
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="checkbox" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'"
										'.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									}	
								}
							else
								for($l=0; $l<count($param['w_choices']); $l++)
								{
									if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$i+$l)
											$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="checkbox" value="" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" other="1" onclick="if(set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)) show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'">'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									else
									{
										$where = '' ;
										$order_by = '' ;
										$db_info = '' ;
										if(isset($param['w_choices_value']))
											$choise_value = $param['w_choices_value'][(int)$param['w_rowcol']*$i+$l];
										else
											$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$i+$l];
							
										if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$i+$l])
										{
											$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$i+$l]);
											$where = "where='".$w_choices_params[0]."'";
											$w_choices_params = explode('[db_info]',$w_choices_params[1]);
											$order_by = "order_by='".$w_choices_params[0]."'";
											$db_info = "db_info='".$w_choices_params[1]."'";
										}
									
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="checkbox" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									}
								}
							
							$rep.='</div>';	
                }
                
                if(count($param['w_choices'])%$param['w_rowcol']!=0)
                {
                  $rep.='<div id="'.$id.'_element_tr'.((int)(count($param['w_choices'])/(int)$param['w_rowcol'])).'" style="display: table-row;">';
                  
                  for($k=0; $k<count($param['w_choices'])%$param['w_rowcol']; $k++)
                  {
                    $l = count($param['w_choices']) - count($param['w_choices'])%$param['w_rowcol'] + $k;
                    if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$l)
										$rep.='<div valign="top" id="'.$id.'_td_little'.$l.'" idi="'.$l.'" style="display: table-cell;"><input type="checkbox" value="" id="'.$id.'_elementform_id_temp'.$l.'" name="'.$id.'_elementform_id_temp'.$l.'" other="1" onclick="if(set_checked(&quot;'.$id.'&quot;,&quot;'.$l.'&quot;,&quot;form_id_temp&quot;)) show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$l.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$l.'">'.$param['w_choices'][$l].'</label></div>';
								else
								{
									$where = '' ;
									$order_by = '' ;
									$db_info = '' ;
									if(isset($param['w_choices_value']))
										$choise_value = $param['w_choices_value'][$l];
									else
										$choise_value = $param['w_choices'][$l];
							
									if(isset($param['w_choices_params']) && $param['w_choices_params'][$l])
									{
										$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$l]);
										$where = "where='".$w_choices_params[0]."'";
										$w_choices_params = explode('[db_info]',$w_choices_params[1]);
										$order_by = "order_by='".$w_choices_params[0]."'";
										$db_info = "db_info='".$w_choices_params[1]."'";
									}
									$rep.='<div valign="top" id="'.$id.'_td_little'.$l.'" idi="'.$l.'" style="display: table-cell;"><input type="checkbox" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.$l.'" name="'.$id.'_elementform_id_temp'.$l.'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.$l.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$l.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$l.'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][$l].'</label></div>';
								}	
                  }
                  
                  $rep.='</div>';	
                }
                
      
              
            }
            $rep.='</div></div></div></div>';
              break;
            }
            case 'type_radio':
            {
            
              $params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');
              $temp=$params;
			  if(strpos($temp, 'w_field_option_pos') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos','w_field_option_pos','w_flow','w_choices','w_choices_checked','w_rowcol', 'w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_value_disabled', 'w_choices_value', 'w_choices_params','w_class');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              if(!isset($param['w_value_disabled']))
						$param['w_value_disabled'] = 'no';
					
			  if(!isset($param['w_field_option_pos']))
						$param['w_field_option_pos'] = 'left';
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
			  
              if(isset($param['w_choices_value']))
					{
						$param['w_choices_value'] = explode('***',$param['w_choices_value']);
						$param['w_choices_params'] = explode('***',$param['w_choices_params']);	
					}
              
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='checked="checked"';
                else
                  $param['w_choices_checked'][$key]='';
              }	
              
              $rep='<div id="wdform_field'.$id.'" type="type_radio" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_radio" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_randomize'].'" name="'.$id.'_randomizeform_id_temp" id="'.$id.'_randomizeform_id_temp"><input type="hidden" value="'.$param['w_allow_other'].'" name="'.$id.'_allow_otherform_id_temp" id="'.$id.'_allow_otherform_id_temp"><input type="hidden" value="'.$param['w_allow_other_num'].'" name="'.$id.'_allow_other_numform_id_temp" id="'.$id.'_allow_other_numform_id_temp"><input type="hidden" value="'.$param['w_rowcol'].'" name="'.$id.'_rowcol_numform_id_temp" id="'.$id.'_rowcol_numform_id_temp"><input type="hidden" value="'.$param['w_field_option_pos'].'" id="'.$id.'_option_left_right"><input type="hidden" value="'.$param['w_value_disabled'].'" name="'.$id.'_value_disabledform_id_temp" id="'.$id.'_value_disabledform_id_temp"><div style="display: table;"><div id="'.$id.'_table_little" style="display: table-row-group;" '.($param['w_flow']=='hor' ? 'for_hor="'.$id.'_hor"' : '').'>';
            
            
              if($param['w_flow']=='hor')
              {
                $j = 0;
                for($i=0; $i<(int)$param['w_rowcol']; $i++)
                {
                  $rep.='<div id="'.$id.'_element_tr'.$i.'" style="display: table-row;">';
                  
                    for($l=0; $l<=(int)(count($param['w_choices'])/$param['w_rowcol']); $l++)
                    {
                      if($j >= count($param['w_choices'])%$param['w_rowcol'] && $l==(int)(count($param['w_choices'])/$param['w_rowcol']))
                      continue;
                      
                      if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$l+$i)
											$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$l+$i).'" idi="'.((int)$param['w_rowcol']*$l+$i).'" style="display: table-cell;"><input type="radio" value="'.$param['w_choices'][(int)$param['w_rowcol']*$l+$i].'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" name="'.$id.'_elementform_id_temp" other="1" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$l+$i).'&quot;,&quot;form_id_temp&quot;); show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$l+$i].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$l+$i).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'">'.$param['w_choices'][(int)$param['w_rowcol']*$l+$i].'</label></div>';
										else	
										{
											$where = '' ;
											$order_by = '' ;
											$db_info = '' ;
											if(isset($param['w_choices_value']))
												$choise_value = $param['w_choices_value'][(int)$param['w_rowcol']*$l+$i];	
											else
												$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$l+$i];
												
											if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$l+$i])
											{
												$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$l+$i]);
												$where = "where='".$w_choices_params[0]."'";
												$w_choices_params = explode('[db_info]',$w_choices_params[1]);
												$order_by = "order_by='".$w_choices_params[0]."'";
												$db_info = "db_info='".$w_choices_params[1]."'";
											}
											
											$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$l+$i).'" idi="'.((int)$param['w_rowcol']*$l+$i).'" style="display: table-cell;"><input type="radio" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" name="'.$id.'_elementform_id_temp" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$l+$i).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$l+$i].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$l+$i).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$l+$i).'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$l+$i].'</label></div>';
										}		
                    }
                    
                  $j++;
                  $rep.='</div>';	
                  
                }
        
              }
              else
              {
                for($i=0; $i<(int)(count($param['w_choices'])/$param['w_rowcol']); $i++)
                {
                  $rep.='<div id="'.$id.'_element_tr'.$i.'" style="display: table-row;">';
							
							if(count($param['w_choices']) > (int)$param['w_rowcol'])
								for($l=0; $l<$param['w_rowcol']; $l++)
								{
									if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$i+$l)
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="radio" value="'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp" other="1" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;); show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].'  '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'">'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									else
									{
										$where = '' ;
										$order_by = '' ;
										$db_info = '' ;
										if(isset($param['w_choices_value']))
											$choise_value = $param['w_choices_value'][(int)$param['w_rowcol']*$i+$l];	
										else
											$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$i+$l];

										if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$i+$l])
										{
											$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$i+$l]);
											$where = "where='".$w_choices_params[0]."'";
											$w_choices_params = explode('[db_info]',$w_choices_params[1]);
											$order_by = "order_by='".$w_choices_params[0]."'";
											$db_info = "db_info='".$w_choices_params[1]."'";
										}		
									
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="radio" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									}	
								}
							else
								for($l=0; $l<count($param['w_choices']); $l++)
								{
									if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==(int)$param['w_rowcol']*$i+$l)
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="radio" value="'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp" other="1" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;); show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").'  disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'">'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									else
									{
										$where = '' ;
										$order_by = '' ;
										$db_info = '' ;
										if(isset($param['w_choices_value']))
											$choise_value = $param['w_choices_value'][(int)$param['w_rowcol']*$i+$l];	
										else
											$choise_value = $param['w_choices'][(int)$param['w_rowcol']*$i+$l];

										if(isset($param['w_choices_params']) && $param['w_choices_params'][(int)$param['w_rowcol']*$i+$l])
										{
											$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][(int)$param['w_rowcol']*$i+$l]);
											$where = "where='".$w_choices_params[0]."'";
											$w_choices_params = explode('[db_info]',$w_choices_params[1]);
											$order_by = "order_by='".$w_choices_params[0]."'";
											$db_info = "db_info='".$w_choices_params[1]."'";
										}		
									
										$rep.='<div valign="top" id="'.$id.'_td_little'.((int)$param['w_rowcol']*$i+$l).'" idi="'.((int)$param['w_rowcol']*$i+$l).'" style="display: table-cell;"><input type="radio" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" name="'.$id.'_elementform_id_temp" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.((int)$param['w_rowcol']*$i+$l).'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][(int)$param['w_rowcol']*$i+$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.((int)$param['w_rowcol']*$i+$l).'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.((int)$param['w_rowcol']*$i+$l).'" '.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][(int)$param['w_rowcol']*$i+$l].'</label></div>';
									}	
								}
							
							$rep.='</div>';	
                }
                
                if(count($param['w_choices'])%$param['w_rowcol']!=0)
                {
                  $rep.='<div id="'.$id.'_element_tr'.((int)(count($param['w_choices'])/(int)$param['w_rowcol'])).'" style="display: table-row;">';
							
							for($k=0; $k<count($param['w_choices'])%$param['w_rowcol']; $k++)
							{
								$l = count($param['w_choices']) - count($param['w_choices'])%$param['w_rowcol'] + $k;
								if($param['w_allow_other']=="yes" && $param['w_allow_other_num']==$l)
									$rep.='<div valign="top" id="'.$id.'_td_little'.$l.'" idi="'.$l.'" style="display: table-cell;"><input type="radio" value="'.$param['w_choices'][$l].'" id="'.$id.'_elementform_id_temp'.$l.'" name="'.$id.'_elementform_id_temp" other="1" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$l.'&quot;,&quot;form_id_temp&quot;); show_other_input(&quot;'.$id.'&quot;,&quot;form_id_temp&quot;);" '.$param['w_choices_checked'][$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$l.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$l.'">'.$param['w_choices'][$l].'</label></div>';
								else
								{
									$where = '' ;
									$order_by = '' ;
									$db_info = '' ;
									if(isset($param['w_choices_value']))
										$choise_value = $param['w_choices_value'][$l];
									else
										$choise_value = $param['w_choices'][$l];
									
									if(isset($param['w_choices_params']) && $param['w_choices_params'][$l])
									{
										$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$l]);
										$where = "where='".$w_choices_params[0]."'";
										$w_choices_params = explode('[db_info]',$w_choices_params[1]);
										$order_by = "order_by='".$w_choices_params[0]."'";
										$db_info = "db_info='".$w_choices_params[1]."'";
									}
								
									$rep.='<div valign="top" id="'.$id.'_td_little'.$l.'" idi="'.$l.'" style="display: table-cell;"><input type="radio" value="'.$choise_value.'" id="'.$id.'_elementform_id_temp'.$l.'" name="'.$id.'_elementform_id_temp" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$l.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$l].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$l.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$l.'"
									'.$where.' '.$order_by.' '.$db_info.'>'.$param['w_choices'][$l].'</label></div>';
								}	
							}
							
							$rep.='</div>';	
                }
                
              }
                  
              
        
            $rep.='</div></div></div></div>';
            
              break;
            }
            case 'type_own_select':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_checked', 'w_choices_disabled','w_required','w_class');
              $temp=$params;
			  if(strpos($temp, 'w_choices_value') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_checked', 'w_choices_disabled', 'w_required', 'w_value_disabled', 'w_choices_value', 'w_choices_params', 'w_class');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
              $param['w_choices_disabled']	= explode('***',$param['w_choices_disabled']);
			  
              if(isset($param['w_choices_value']))
					{
						$param['w_choices_value'] = explode('***',$param['w_choices_value']);
						$param['w_choices_params'] = explode('***',$param['w_choices_params']);	
					}
					
			   if(!isset($param['w_value_disabled']))
						$param['w_value_disabled'] = 'no';
						
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='selected="selected"';
                else
                  $param['w_choices_checked'][$key]='';
              }
              
              $rep='<div id="wdform_field'.$id.'" type="type_own_select" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; "><input type="hidden" value="type_own_select" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_value_disabled'].'" name="'.$id.'_value_disabledform_id_temp" id="'.$id.'_value_disabledform_id_temp"><select id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" onchange="set_select(this)" style="width: '.$param['w_size'].'px;"  '.$param['attributes'].' disabled>';
              foreach($param['w_choices'] as $key => $choice)
              {
                        $where = '';
						$order_by = '';
						$db_info = '';
						$choice_value = $param['w_choices_disabled'][$key]=='true' ? '' : (isset($param['w_choices_value']) ? $param['w_choices_value'][$key] : $choice);
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}
					
						$rep.='<option id="'.$id.'_option'.$key.'" value="'.$choice_value.'" onselect="set_select(&quot;'.$id.'_option'.$key.'&quot;)" '.$param['w_choices_checked'][$key].' '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</option>';
              }
              $rep.='</select></div></div>';
              break;
            }
            
            case 'type_country':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_countries','w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_countries']	= explode('***',$param['w_countries']);
            
              $rep='<div id="wdform_field'.$id.'" type="type_country" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; "><input type="hidden" value="type_country" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><select id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" style="width: '.$param['w_size'].'px;"  '.$param['attributes'].' disabled>';
              foreach($param['w_countries'] as $key => $choice)
              {
                $choice_value=$choice;
                $rep.='<option value="'.$choice_value.'">'.$choice.'</option>';
              }
              $rep.='</select></div></div>';
              break;
            }
            
            case 'type_time':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_time_type','w_am_pm','w_sec','w_hh','w_mm','w_ss','w_mini_labels','w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
            
              $w_mini_labels = explode('***',$param['w_mini_labels']);
              
            
              if($param['w_sec']=='1')
              {
                $w_sec = '<div align="center" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;:&nbsp;</span></div><div id="'.$id.'_td_time_input3" style="width: 32px; display: table-cell;"><input type="text" value="'.$param['w_ss'].'" class="time_box" id="'.$id.'_ssform_id_temp" name="'.$id.'_ssform_id_temp" onkeypress="return check_second(event, &quot;'.$id.'_ssform_id_temp&quot;)" onkeyup="change_second(&quot;'.$id.'_ssform_id_temp&quot;)" onblur="add_0(&quot;'.$id.'_ssform_id_temp&quot;)" '.$param['attributes'].' disabled /></div>';
                $w_sec_label='<div style="display: table-cell;"></div><div id="'.$id.'_td_time_label3" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_ss">'.$w_mini_labels[2].'</label></div>';
              }
              else
              {
                $w_sec = '';
                $w_sec_label='';
              }
              
              if($param['w_time_type']=='12')
              {
                if($param['w_am_pm']=='am')
                {
                  $am_ = "selected=\"selected\"";
                  $pm_ = "";
                }	
                else
                {
                  $am_ = "";
                  $pm_ = "selected=\"selected\"";
                  
                }	
              
              $w_time_type = '<div id="'.$id.'_am_pm_select" class="td_am_pm_select" style="display: table-cell;"><select class="am_pm_select" name="'.$id.'_am_pmform_id_temp" id="'.$id.'_am_pmform_id_temp" onchange="set_sel_am_pm(this)" '.$param['attributes'].'><option value="am" '.$am_.'>AM</option><option value="pm" '.$pm_.'>PM</option></select></div>';
              
              $w_time_type_label = '<div id="'.$id.'_am_pm_label" class="td_am_pm_select" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_am_pm">'.$w_mini_labels[3].'</label></div>';
              
              }
              else
              {
              $w_time_type='';
              $w_time_type_label = '';
              }

              
              $rep ='<div id="wdform_field'.$id.'" type="type_time" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_time" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><div id="'.$id.'_table_time" style="display: table;"><div id="'.$id.'_tr_time1" style="display: table-row;"><div id="'.$id.'_td_time_input1" style="width: 32px; display: table-cell;"><input type="text" value="'.$param['w_hh'].'" class="time_box" id="'.$id.'_hhform_id_temp" name="'.$id.'_hhform_id_temp" onkeypress="return check_hour(event, &quot;'.$id.'_hhform_id_temp&quot;, &quot;23&quot;)" onkeyup="change_hour(event, &quot;'.$id.'_hhform_id_temp&quot;,&quot;23&quot;)" onblur="add_0(&quot;'.$id.'_hhform_id_temp&quot;)" '.$param['attributes'].' disabled/></div><div align="center" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;:&nbsp;</span></div><div id="'.$id.'_td_time_input2" style="width: 32px; display: table-cell;"><input type="text" value="'.$param['w_mm'].'" class="time_box" id="'.$id.'_mmform_id_temp" name="'.$id.'_mmform_id_temp" onkeypress="return check_minute(event, &quot;'.$id.'_mmform_id_temp&quot;)" onkeyup="change_minute(event, &quot;'.$id.'_mmform_id_temp&quot;)" onblur="add_0(&quot;'.$id.'_mmform_id_temp&quot;)" '.$param['attributes'].' disabled/></div>'.$w_sec.$w_time_type.'</div><div id="'.$id.'_tr_time2" style="display: table-row;"><div id="'.$id.'_td_time_label1" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_hh">'.$w_mini_labels[0].'</label></div><div style="display: table-cell;"></div><div id="'.$id.'_td_time_label2" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_mm">'.$w_mini_labels[1].'</label></div>'.$w_sec_label.$w_time_type_label.'</div></div></div></div>';
              
              break;
            }
            case 'type_date':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_date','w_required','w_class','w_format','w_but_val');
              $temp = $params;
			  if(strpos($temp, 'w_disable_past_days') > -1)
				$params_names = array('w_field_label_size','w_field_label_pos','w_date','w_required','w_class','w_format','w_but_val', 'w_disable_past_days');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_disable_past_days'] = isset($param['w_disable_past_days']) ? $param['w_disable_past_days'] : 'no';
			  $disable_past_days = $param['w_disable_past_days'] == 'yes' ? 'true' : 'false';

              $rep ='<div id="wdform_field'.$id.'" type="type_date" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_date" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_disable_past_days'].'" name="'.$id.'_dis_past_daysform_id_temp" id="'.$id.'_dis_past_daysform_id_temp"><input type="text" value="'.$param['w_date'].'" class="wdform-date" id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" maxlength="10" size="10" onchange="change_value(&quot;'.$id.'_elementform_id_temp&quot;)" '.$param['attributes'].' disabled/><input id="'.$id.'_buttonform_id_temp" class="button" type="reset" value="'.$param['w_but_val'].'" format="'.$param['w_format'].'" src="templates/bluestork/images/system/calendar.png?ver='. get_option("wd_form_maker_version").'" alt="calendario" '.$param['attributes'].' onclick="return showCalendar(&quot;'.$id.'_elementform_id_temp&quot; , &quot;'.$param['w_format'].'&quot;, '.$disable_past_days.')"></div></div>';
              
              break;
            }
            case 'type_date_fields':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_day','w_month','w_year','w_day_type','w_month_type','w_year_type','w_day_label','w_month_label','w_year_label','w_day_size','w_month_size','w_year_size','w_required','w_class','w_from','w_to','w_divider');
              
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
            
      
              if($param['w_day_type']=="SELECT")
              {

              
                $w_day_type = '<select id="'.$id.'_dayform_id_temp" name="'.$id.'_dayform_id_temp" onchange="set_select(this)" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].' disabled><option value=""></option>';
                for($k=0; $k<=31; $k++)
                {
                  if($k<10)
                  {
                    if($param['w_day']=='0'.$k)
                    $selected = "selected=\"selected\"";
                    else
                    $selected = "";
                    
                    $w_day_type .= '<option value="0'.$k.'" '.$selected.'>0'.$k.'</option>';
                  }
                  else
                  {
                  if($param['w_day']==''.$k)
                    $selected = "selected=\"selected\"";
                    else
                    $selected = "";
                    
                    $w_day_type .= '<option value="'.$k.'" '.$selected.'>'.$k.'</option>';
                  }
                  
                  
                  
                }
                $w_day_type .= '</select>';
              }
              else
					{
						$w_day_type = '<input type="text" value="'.$param['w_day'].'" id="'.$id.'_dayform_id_temp" name="'.$id.'_dayform_id_temp" onchange="change_value(&quot;'.$id.'_dayform_id_temp&quot;)" onkeypress="return check_day(event, &quot;'.$id.'_dayform_id_temp&quot;)" onblur="if (this.value==&quot;0&quot;) this.value=&quot;&quot;; else add_0(&quot;'.$id.'_dayform_id_temp&quot;)" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].' disabled/>';
					}

					if($param['w_month_type']=="SELECT")
					{
					
						$w_month_type = '<select id="'.$id.'_monthform_id_temp" name="'.$id.'_monthform_id_temp" onchange="set_select(this)" style="width: '.$param['w_month_size'].'px;" '.$param['attributes'].' disabled><option value=""></option><option value="01" '.($param['w_month']=="01" ? "selected=\"selected\"": "").'  ><!--repstart-->January<!--repend--></option><option value="02" '.($param['w_month']=="02" ? "selected=\"selected\"": "").'><!--repstart-->February<!--repend--></option><option value="03" '.($param['w_month']=="03"? "selected=\"selected\"": "").'><!--repstart-->March<!--repend--></option><option value="04" '.($param['w_month']=="04" ? "selected=\"selected\"": "").' ><!--repstart-->April<!--repend--></option><option value="05" '.($param['w_month']=="05" ? "selected=\"selected\"": "").' ><!--repstart-->May<!--repend--></option><option value="06" '.($param['w_month']=="06" ? "selected=\"selected\"": "").' ><!--repstart-->June<!--repend--></option><option value="07" '.($param['w_month']=="07" ? "selected=\"selected\"": "").' ><!--repstart-->July<!--repend--></option><option value="08" '.($param['w_month']=="08" ? "selected=\"selected\"": "").' ><!--repstart-->August<!--repend--></option><option value="09" '.($param['w_month']=="09" ? "selected=\"selected\"": "").' ><!--repstart-->September<!--repend--></option><option value="10" '.($param['w_month']=="10" ? "selected=\"selected\"": "").' ><!--repstart-->October<!--repend--></option><option value="11" '.($param['w_month']=="11" ? "selected=\"selected\"": "").'><!--repstart-->November<!--repend--></option><option value="12" '.($param['w_month']=="12" ? "selected=\"selected\"": "").' ><!--repstart-->December<!--repend--></option></select>';
					
					}
					else
					{
					$w_month_type = '<input type="text" value="'.$param['w_month'].'" id="'.$id.'_monthform_id_temp" name="'.$id.'_monthform_id_temp" onkeypress="return check_month(event, &quot;'.$id.'_monthform_id_temp&quot;)" onchange="change_value(&quot;'.$id.'_monthform_id_temp&quot;)" onblur="if (this.value==&quot;0&quot;) this.value=&quot;&quot;; else add_0(&quot;'.$id.'_monthform_id_temp&quot;)" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].' disabled/>';
					
					}

					if($param['w_year_type']=="SELECT")
					{
						$w_year_type = '<select id="'.$id.'_yearform_id_temp" name="'.$id.'_yearform_id_temp" onchange="set_select(this)" from="'.$param['w_from'].'" to="'.$param['w_to'].'" style="width: '.$param['w_year_size'].'px;" '.$param['attributes'].' disabled><option value=""></option>';
                for($k=$param['w_to']; $k>=$param['w_from']; $k--)
                {
                  if($param['w_year']==$k)
                  $selected = "selected=\"selected\"";
                  else
                  $selected = "";
                  
                  $w_year_type .= '<option value="'.$k.'" '.$selected.'>'.$k.'</option>';
                }
                $w_year_type .= '</select>';
              
              }
              else
              {
                $w_year_type = '<input type="text" value="'.$param['w_year'].'" id="'.$id.'_yearform_id_temp" name="'.$id.'_yearform_id_temp" onchange="change_year(&quot;'.$id.'_yearform_id_temp&quot;)" onkeypress="return check_year1(event, &quot;'.$id.'_yearform_id_temp&quot;)" onblur="check_year2(&quot;'.$id.'_yearform_id_temp&quot;)" from="'.$param['w_from'].'" to="'.$param['w_to'].'" style="width: '.$param['w_day_size'].'px;" '.$param['attributes'].' disabled/>';
              }

              
              $rep ='<div id="wdform_field'.$id.'" type="type_date_fields" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_date_fields" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><div id="'.$id.'_table_date" style="display: table;"><div id="'.$id.'_tr_date1" style="display: table-row;"><div id="'.$id.'_td_date_input1" style="display: table-cell;">
              '.$w_day_type.'
              
              </div><div id="'.$id.'_td_date_separator1" style="display: table-cell;"><span id="'.$id.'_separator1" class="wdform_separator">'.$param['w_divider'].'</span></div><div id="'.$id.'_td_date_input2" style="display: table-cell;">'.$w_month_type.'</div><div id="'.$id.'_td_date_separator2" style="display: table-cell;"><span id="'.$id.'_separator2" class="wdform_separator">'.$param['w_divider'].'</span></div><div id="'.$id.'_td_date_input3" style="display: table-cell;">'.$w_year_type.'</div></div><div id="'.$id.'_tr_date2" style="display: table-row;"><div id="'.$id.'_td_date_label1" style="display: table-cell;"><label class="mini_label" id="'.$id.'_day_label">'.$param['w_day_label'].'</label></div><div style="display: table-cell;"></div><div id="'.$id.'_td_date_label2" style="display: table-cell;"><label class="mini_label" id="'.$id.'_month_label">'.$param['w_month_label'].'</label></div><div style="display: table-cell;"></div><div id="'.$id.'_td_date_label3" style="display: table-cell;"><label class="mini_label" id="'.$id.'_year_label">'.$param['w_year_label'].'</label></div></div></div></div></div>';
              
              break;
            }
            case 'type_file_upload':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_destination','w_extension','w_max_size','w_required','w_multiple','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                if (isset($temp[1])) {
                  $temp = $temp[1];
                }
                else {
                  $temp = '';
                }
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $multiple = ($param['w_multiple']=="yes" ? "multiple='multiple'" : "");	

              $rep ='<div id="wdform_field'.$id.'" type="type_file_upload" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_file_upload" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="***max_sizeskizb'.$id.'***'.$param['w_max_size'].'***max_sizeverj'.$id.'***" id="'.$id.'_max_size" name="'.$id.'_max_size"><input type="hidden" value="***destinationskizb'.$id.'***'.$param['w_destination'].'***destinationverj'.$id.'***" id="'.$id.'_destination" name="'.$id.'_destination"><input type="hidden" value="***extensionskizb'.$id.'***'.$param['w_extension'].'***extensionverj'.$id.'***" id="'.$id.'_extension" name="'.$id.'_extension"><input type="file" class="file_upload" id="'.$id.'_elementform_id_temp" name="'.$id.'_fileform_id_temp"  '.$multiple.' '.$param['attributes'].' disabled/></div></div>';
              
              break;
            }
            case 'type_captcha':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_digit','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              
              $rep ='<div id="wdform_field'.$id.'" type="type_captcha" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display:'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_captcha" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div style="display: table;"><div style="display: table-row;"><div valign="middle" style="display: table-cell;"><img type="captcha" digit="'.$param['w_digit'].'" src="' . add_query_arg(array('action' => 'formcontactwdcaptcha', 'digit' => $param['w_digit'], 'i' => 'form_id_temp'), admin_url('admin-ajax.php')) . '" id="_wd_captchaform_id_temp" class="captcha_img" onclick="captcha_refresh(&quot;_wd_captcha&quot;,&quot;form_id_temp&quot;)" '.$param['attributes'].'></div><div valign="middle" style="display: table-cell;"><div class="captcha_refresh" id="_element_refreshform_id_temp" onclick="captcha_refresh(&quot;_wd_captcha&quot;,&quot;form_id_temp&quot;)" '.$param['attributes'].'></div></div></div><div style="display: table-row;"><div style="display: table-cell;"><input type="text" class="captcha_input" id="_wd_captcha_inputform_id_temp" name="captcha_input" style="width: '.($param['w_digit']*10+15).'px;" '.$param['attributes'].' disabled/></div></div></div></div></div>';
              
              break;
            }
			case 'type_arithmetic_captcha':
            {
              $params_names=array('w_field_label_size','w_field_label_pos', 'w_count', 'w_operations','w_class', 'w_input_size');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
			 
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
			  $param['w_count'] = $param['w_count'] ? $param['w_count'] : 1;
              $param['w_operations'] = $param['w_operations'] ? $param['w_operations'] : '+, -, *, /';
              $param['w_input_size'] = $param['w_input_size'] ? $param['w_input_size'] : 60;
              
              $rep ='<div id="wdform_field'.$id.'" type="type_arithmetic_captcha" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display:'.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_captcha" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div style="display: table;"><div style="display: table-row;"><div style="display: table-cell;"><img type="captcha" operations_count="'.$param['w_count'].'" operations="'.$param['w_operations'].'" input_size="'.$param['w_input_size'].'" src="' . add_query_arg(array('action' => 'formcontactwdmathcaptcha', 'operations_count' => $param['w_count'], 'operations' => $param['w_operations'], 'i' => 'form_id_temp'), admin_url('admin-ajax.php')) . '" id="_wd_arithmetic_captchaform_id_temp" class="arithmetic_captcha_img" onclick="captcha_refresh(&quot;_wd_arithmetic_captcha&quot;,&quot;form_id_temp&quot;)" '.$param['attributes'].'></div><div style="display: table-cell;"><input type="text" class="arithmetic_captcha_input" id="_wd_arithmetic_captcha_inputform_id_temp" name="arithmetic_captcha_input" onkeypress="return check_isnum(event)" style="width: '.$param['w_input_size'].'px;" '.$param['attributes'].' disabled/></div><div style="display: table-cell; vertical-align: middle;"><div class="captcha_refresh" id="_element_refreshform_id_temp" onclick="captcha_refresh(&quot;_wd_arithmetic_captcha&quot;,&quot;form_id_temp&quot;)" '.$param['attributes'].'></div></div></div></div></div></div>';
              
              break;
            }


            case 'type_recaptcha':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_public','w_private','w_theme','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              
              $rep ='<div id="wdform_field'.$id.'" type="type_recaptcha" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_recaptcha" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div id="wd_recaptchaform_id_temp" public_key="'.$param['w_public'].'" private_key="'.$param['w_private'].'" theme="'.$param['w_theme'].'" '.$param['attributes'].'><span style="color: red; font-style: italic;">Recaptcha doesn\'t display in back end</span></div></div></div>';
              
              break;
            }
            
            case 'type_hidden':
            {
              $params_names=array('w_name','w_value');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              $param['w_name'] = str_replace('&nbsp;','',$param['w_name']);
              $rep ='<div id="wdform_field'.$id.'" type="type_hidden" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" style="display: table-cell;"><span id="'.$id.'_element_labelform_id_temp" style="display: none;">'.$param['w_name'].'</span><span style="color: red; font-size: 13px;">Hidden field</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" style="display: table-cell; padding-left:7px;"><input type="hidden" value="'.$param['w_value'].'" id="'.$id.'_elementform_id_temp" name="'.$param['w_name'].'" '.$param['attributes'].'><input type="hidden" value="type_hidden" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div><span align="left">Name: </span><span align="left" id="'.$id.'_hidden_nameform_id_temp">'.$param['w_name'].'</span></div><div><span align="left">Value: </span><span align="left" id="'.$id.'_hidden_valueform_id_temp">'.$param['w_value'].'</span></div></div></div>';
              
              break;
            }
            case 'type_mark_map':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_center_x','w_center_y','w_long','w_lat','w_zoom','w_width','w_height','w_info','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
            
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
            
              $rep ='<div id="wdform_field'.$id.'" type="type_mark_map" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_mark_map" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div id="'.$id.'_elementform_id_temp" long0="'.$param['w_long'].'" lat0="'.$param['w_lat'].'" zoom="'.$param['w_zoom'].'" info0="'.$param['w_info'].'" center_x="'.$param['w_center_x'].'" center_y="'.$param['w_center_y'].'" style="width: '.$param['w_width'].'px; height: '.$param['w_height'].'px;" '.$param['attributes'].'></div></div></div>	';
              
              break;
            }
            
            case 'type_map':
            {
              $params_names=array('w_center_x','w_center_y','w_long','w_lat','w_zoom','w_width','w_height','w_info','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              
              $marker='';
              
              $param['w_long']	= explode('***',$param['w_long']);
              $param['w_lat']	= explode('***',$param['w_lat']);
              $param['w_info']	= explode('***',$param['w_info']);
              foreach($param['w_long'] as $key => $w_long )
              {
                $marker.='long'.$key.'="'.$w_long.'" lat'.$key.'="'.$param['w_lat'][$key].'" info'.$key.'="'.$param['w_info'][$key].'"';
              }
            
              $rep ='<div id="wdform_field'.$id.'" type="type_map" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><span id="'.$id.'_element_labelform_id_temp" style="display: none;">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><input type="hidden" value="type_map" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div id="'.$id.'_elementform_id_temp" zoom="'.$param['w_zoom'].'" center_x="'.$param['w_center_x'].'" center_y="'.$param['w_center_y'].'" style="width: '.$param['w_width'].'px; height: '.$param['w_height'].'px;" '.$marker.' '.$param['attributes'].'></div></div></div>';
              
              break;
            }
            case 'type_paypal_price':
            {
                        
              $params_names=array('w_field_label_size','w_field_label_pos','w_first_val','w_title', 'w_mini_labels','w_size','w_required','w_hide_cents','w_class','w_range_min','w_range_max');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $input_active = ($param['w_first_val']==$param['w_title'] ? "input_deactive" : "input_active");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $hide_cents = ($param['w_hide_cents']=="yes" ? "none;" : "table-cell;");	
            

              $w_first_val = explode('***',$param['w_first_val']);
              $w_title = explode('***',$param['w_title']);
              $w_mini_labels = explode('***',$param['w_mini_labels']);
              
              $rep ='<div id="wdform_field'.$id.'" type="type_paypal_price" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required"style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_paypal_price" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_range_min'].'" name="'.$id.'_range_minform_id_temp" id="'.$id.'_range_minform_id_temp"><input type="hidden" value="'.$param['w_range_max'].'" name="'.$id.'_range_maxform_id_temp" id="'.$id.'_range_maxform_id_temp"><div id="'.$id.'_table_price" style="display: table;"><div id="'.$id.'_tr_price1" style="display: table-row;"><div id="'.$id.'_td_name_currency" style="display: table-cell;"><span class="wdform_colon" style="vertical-align: middle;"><!--repstart-->&nbsp;$&nbsp;<!--repend--></span></div><div id="'.$id.'_td_name_dollars" style="display: table-cell;"><input type="text" class="'.$input_active.'" id="'.$id.'_element_dollarsform_id_temp" name="'.$id.'_element_dollarsform_id_temp" value="'.$w_first_val[0].'" title="'.$w_title[0].'"onfocus="delete_value(&quot;'.$id.'_element_dollarsform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_element_dollarsform_id_temp&quot;)"onchange="change_value(&quot;'.$id.'_element_dollarsform_id_temp&quot;)" onkeypress="return check_isnum(event)" style="width: '.$param['w_size'].'px;" '.$param['attributes'].' disabled/></div><div id="'.$id.'_td_name_divider" style="display: '.$hide_cents.';"><span class="wdform_colon" style="vertical-align: middle;">&nbsp;.&nbsp;</span></div><div id="'.$id.'_td_name_cents" style="display: '.$hide_cents.'"><input type="text" class="'.$input_active.'" id="'.$id.'_element_centsform_id_temp" name="'.$id.'_element_centsform_id_temp" value="'.$w_first_val[1].'" title="'.$w_title[1].'"onfocus="delete_value(&quot;'.$id.'_element_centsform_id_temp&quot;)" onblur="return_value(&quot;'.$id.'_element_centsform_id_temp&quot;); add_0(&quot;'.$id.'_element_centsform_id_temp&quot;)"onchange="change_value(&quot;'.$id.'_element_centsform_id_temp&quot;)" onkeypress="return check_isnum_interval(event,&quot;'.$id.'_element_centsform_id_temp&quot;,0,99)"style="width: 30px;" '.$param['attributes'].' disabled/></div></div><div id="'.$id.'_tr_price2" style="display: table-row;"><div style="display: table-cell;"><label class="mini_label"></label></div><div align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_dollars">'.$w_mini_labels[0].'</label></div><div id="'.$id.'_td_name_label_divider" style="display: '.$hide_cents.'"><label class="mini_label"></label></div><div align="left" id="'.$id.'_td_name_label_cents" style="display: '.$hide_cents.'"><label class="mini_label" id="'.$id.'_mini_label_cents">'.$w_mini_labels[1].'</label></div></div></div></div></div>';
              break;
            }
            
            case 'type_paypal_select':
            {
            $params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_price','w_choices_checked', 'w_choices_disabled','w_required','w_quantity', 'w_quantity_value','w_class','w_property','w_property_values');
              $temp=$params;
			  if(strpos($temp, 'w_choices_params') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos','w_size','w_choices','w_choices_price','w_choices_checked', 'w_choices_disabled','w_required','w_quantity', 'w_quantity_value', 'w_choices_params', 'w_class', 'w_property', 'w_property_values');	
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }

              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
                 
              $param['w_choices_price']	= explode('***',$param['w_choices_price']);
                 
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
                
              $param['w_choices_disabled']	= explode('***',$param['w_choices_disabled']);
              $param['w_property']	= explode('***',$param['w_property']);
              $param['w_property_values']	= explode('***',$param['w_property_values']);
             if(isset($param['w_choices_params']))
						$param['w_choices_params'] = explode('***',$param['w_choices_params']);	
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='selected="selected"';
                else
                  $param['w_choices_checked'][$key]='';
              }

              
              $rep='<div id="wdform_field'.$id.'" type="type_paypal_select" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; "><input type="hidden" value="type_paypal_select" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><select id="'.$id.'_elementform_id_temp" name="'.$id.'_elementform_id_temp" onchange="set_select(this)" style="width: '.$param['w_size'].'px;"  '.$param['attributes'].' disabled>';
					foreach($param['w_choices'] as $key => $choice)
					{
						$where = '';
						$order_by = '';
						$db_info = '';
						$choice_value = $param['w_choices_disabled'][$key]=="true" ? '' : $param['w_choices_price'][$key];
							
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}	
						 $rep.='<option id="'.$id.'_option'.$key.'" value="'.$choice_value.'" onselect="set_select(&quot;'.$id.'_option'.$key.'&quot;)" '.$param['w_choices_checked'][$key].' '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</option>';
					}
					$rep.='</select><div id="'.$id.'_divform_id_temp">';
					if($param['w_quantity']=="yes")
						$rep.='<span id="'.$id.'_element_quantity_spanform_id_temp" style="margin-right: 15px;"><label class="mini_label" id="'.$id.'_element_quantity_label_form_id_temp" style="margin-right: 5px;"><!--repstart-->Quantity<!--repend--></label><input type="text" value="'.$param['w_quantity_value'].'" id="'.$id.'_element_quantityform_id_temp" name="'.$id.'_element_quantityform_id_temp" onkeypress="return check_isnum(event)" onchange="change_value(&quot;'.$id.'_element_quantityform_id_temp&quot;, this.value)" style="width: 30px; margin: 2px 0px;" disabled /></span>';
					if($param['w_property'][0])					
					foreach($param['w_property'] as $key => $property)
					{
	
					$rep.='
					<span id="'.$id.'_property_'.$key.'" style="margin-right: 15px;">
					
					<label class="mini_label" id="'.$id.'_property_label_form_id_temp'.$key.'" style="margin-right: 5px;">'.$property.'</label>
					<select id="'.$id.'_propertyform_id_temp'.$key.'" name="'.$id.'_propertyform_id_temp'.$key.'" style="width: auto; margin: 2px 0px;" disabled>';
					$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);
					$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   
					foreach($param['w_property_values'][$key] as $subkey => $property_value)
					{
						$rep.='<option id="'.$id.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'">'.$property_value.'</option>';
					}
					$rep.='</select></span>';
					}
					
					$rep.='</div></div></div>';
					break;
            }
            
            case 'type_paypal_checkbox':
            {
                        
              $params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class','w_property','w_property_values','w_quantity','w_quantity_value');
              $temp=$params;
			  if(strpos($temp, 'w_field_option_pos') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_choices_params', 'w_class','w_property','w_property_values','w_quantity','w_quantity_value');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              if(!isset($param['w_field_option_pos']))
						$param['w_field_option_pos'] = 'left';
						
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);				   
              $param['w_choices_price']	= explode('***',$param['w_choices_price']);					
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);		  
              $param['w_property']	= explode('***',$param['w_property']);
              $param['w_property_values']	= explode('***',$param['w_property_values']);
			  
              if(isset($param['w_choices_params']))
						$param['w_choices_params']	= explode('***',$param['w_choices_params']);
					
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='checked="checked"';
                else
                  $param['w_choices_checked'][$key]='';
              }
              
              $rep='<div id="wdform_field'.$id.'" type="type_paypal_checkbox" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="wd_form_label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_paypal_checkbox" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_randomize'].'" name="'.$id.'_randomizeform_id_temp" id="'.$id.'_randomizeform_id_temp"><input type="hidden" value="'.$param['w_allow_other'].'" name="'.$id.'_allow_otherform_id_temp" id="'.$id.'_allow_otherform_id_temp"><input type="hidden" value="'.$param['w_allow_other_num'].'" name="'.$id.'_allow_other_numform_id_temp" id="'.$id.'_allow_other_numform_id_temp"><input type="hidden" value="'.$param['w_field_option_pos'].'" id="'.$id.'_option_left_right"><div style="display: table;"><div id="'.$id.'_table_little" style="display: table-row-group;">';
				
					if($param['w_flow']=='hor')
					{
						$rep.= '<div id="'.$id.'_hor" style="display: table-row;">';
						foreach($param['w_choices'] as $key => $choice)
						{
						    $where ='';
							$order_by ='';
							$db_info = '';
							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
							{
								$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
								$where = "where='".$w_choices_params[0]."'";
								$w_choices_params = explode('[db_info]',$w_choices_params[1]);
								$order_by = "order_by='".$w_choices_params[0]."'";
								$db_info = "db_info='".$w_choices_params[1]."'";
							}
						
							$rep.='<div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="checkbox" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp'.$key.'" value="'.$param['w_choices_price'][$key].'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div>';
						}
						$rep.= '</div>';
					}
					else
					{
						
						foreach($param['w_choices'] as $key => $choice)
						{
						$where ='';
							$order_by ='';
							$db_info ='';
							if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
							{
								$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
								$where = "where='".$w_choices_params[0]."'";
								$w_choices_params = explode('[db_info]',$w_choices_params[1]);
								$order_by = "order_by='".$w_choices_params[0]."'";
								$db_info = "db_info='".$w_choices_params[1]."'";
							}
						
							$rep.='<div id="'.$id.'_element_tr'.$key.'" style="display: table-row;"><div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="checkbox" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp'.$key.'" value="'.$param['w_choices_price'][$key].'" onclick="set_checked(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div></div>';		
					    }
						
					}
					$rep.='</div></div>';

					$rep.='<div id="'.$id.'_divform_id_temp">';
					if($param['w_quantity']=="yes")
						$rep.='<span id="'.$id.'_element_quantity_spanform_id_temp" style="margin-right: 15px;"><label class="mini_label" id="'.$id.'_element_quantity_label_form_id_temp" style="margin-right: 5px;"><!--repstart-->Quantity<!--repend--></label><input type="text" value="'.$param['w_quantity_value'].'" id="'.$id.'_element_quantityform_id_temp" name="'.$id.'_element_quantityform_id_temp" onkeypress="return check_isnum(event)" onchange="change_value(&quot;'.$id.'_element_quantityform_id_temp&quot;, this.value)" style="width: 30px; margin: 2px 0px;" disabled/></span>';
					if($param['w_property'][0])					
					foreach($param['w_property'] as $key => $property)
					{
					$rep.='
					<span id="'.$id.'_property_'.$key.'" style="margin-right: 15px;">
					
					<label class="mini_label" id="'.$id.'_property_label_form_id_temp'.$key.'" style="margin-right: 5px;">'.$property.'</label>
					<select id="'.$id.'_propertyform_id_temp'.$key.'" name="'.$id.'_propertyform_id_temp'.$key.'" style="width: auto; margin: 2px 0px;" disabled>';
					$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);
					$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   
					foreach($param['w_property_values'][$key] as $subkey => $property_value)
					{
						$rep.='<option id="'.$id.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'">'.$property_value.'</option>';
					}
					$rep.='</select></span>';
					}
					
					$rep.='</div></div></div>';
					break;
            }
            case 'type_paypal_radio':
            {
              
              $params_names=array('w_field_label_size','w_field_label_pos','w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class','w_property','w_property_values','w_quantity','w_quantity_value');
              $temp=$params;
			  if(strpos($temp, 'w_field_option_pos') > -1)
						$params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num', 'w_choices_params', 'w_class','w_property','w_property_values','w_quantity','w_quantity_value');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
             if(!isset($param['w_field_option_pos']))
						$param['w_field_option_pos'] = 'left';
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
                 
              $param['w_choices_price']	= explode('***',$param['w_choices_price']);
              
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
                
              $param['w_property']	= explode('***',$param['w_property']);
              $param['w_property_values']	= explode('***',$param['w_property_values']);
			  
              if(isset($param['w_choices_params']))
						$param['w_choices_params']	= explode('***',$param['w_choices_params']);
						
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='checked="checked"';
                else
                  $param['w_choices_checked'][$key]='';
              }
              
              $rep='<div id="wdform_field'.$id.'" type="type_paypal_radio" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="wd_form_label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_paypal_radio" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_randomize'].'" name="'.$id.'_randomizeform_id_temp" id="'.$id.'_randomizeform_id_temp"><input type="hidden" value="'.$param['w_allow_other'].'" name="'.$id.'_allow_otherform_id_temp" id="'.$id.'_allow_otherform_id_temp"><input type="hidden" value="'.$param['w_allow_other_num'].'" name="'.$id.'_allow_other_numform_id_temp" id="'.$id.'_allow_other_numform_id_temp"><input type="hidden" value="'.$param['w_field_option_pos'].'" id="'.$id.'_option_left_right"><div style="display: table;"><div id="'.$id.'_table_little" style="display: table-row-group;">';
				
				if($param['w_flow']=='hor')
				{
					$rep.= '<div id="'.$id.'_hor" style="display: table-row;">';
					foreach($param['w_choices'] as $key => $choice)
					{
					$where ='';
						$order_by ='';
						$db_info ='';
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}
						
						$rep.='<div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="radio" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp" value="'.$param['w_choices_price'][$key].'" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div>';
					}
					$rep.= '</div>';
				}
				else
				{
					
					foreach($param['w_choices'] as $key => $choice)
					{
					
						$where ='';
						$order_by ='';
						$db_info ='';
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}
						
						$rep.='<div id="'.$id.'_element_tr'.$key.'" style="display: table-row;"><div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="radio" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp" value="'.$param['w_choices_price'][$key].'" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div></div>';				
					}
					
				}
					$rep.='</div></div>';

					$rep.='<div id="'.$id.'_divform_id_temp">';
					if($param['w_quantity']=="yes")
						$rep.='<span id="'.$id.'_element_quantity_spanform_id_temp" style="margin-right: 15px;"><label class="mini_label" id="'.$id.'_element_quantity_label_form_id_temp" style="margin-right: 5px;"><!--repstart-->Quantity<!--repend--></label><input type="text" value="'.$param['w_quantity_value'].'" id="'.$id.'_element_quantityform_id_temp" name="'.$id.'_element_quantityform_id_temp" onkeypress="return check_isnum(event)" onchange="change_value(&quot;'.$id.'_element_quantityform_id_temp&quot;, this.value)" style="width: 30px; margin: 2px 0px;" disabled/></span>';
					if($param['w_property'][0])					
					foreach($param['w_property'] as $key => $property)
					{
					$rep.='
					<span id="'.$id.'_property_'.$key.'" style="margin-right: 15px;">
					
					<label class="mini_label" id="'.$id.'_property_label_form_id_temp'.$key.'" style="margin-right: 5px;">'.$property.'</label>
					<select id="'.$id.'_propertyform_id_temp'.$key.'" name="'.$id.'_propertyform_id_temp'.$key.'" style="width: auto; margin: 2px 0px;" disabled>';
					$param['w_property_values'][$key]	= explode('###',$param['w_property_values'][$key]);
					$param['w_property_values'][$key]	= array_slice($param['w_property_values'][$key],1, count($param['w_property_values'][$key]));   
					foreach($param['w_property_values'][$key] as $subkey => $property_value)
					{
						$rep.='<option id="'.$id.'_'.$key.'_option'.$subkey.'" value="'.$property_value.'">'.$property_value.'</option>';
					}
					$rep.='</select></span>';
					}
					
					$rep.='</div></div></div>';
				
					break;
            }
            case 'type_paypal_shipping':
            {
              
              $params_names=array('w_field_label_size','w_field_label_pos', 'w_field_option_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_class');
              $temp=$params;
			  if(strpos($temp, 'w_field_option_pos') > -1)
				$params_names=array('w_field_label_size','w_field_label_pos', 'w_flow','w_choices','w_choices_price','w_choices_checked','w_required','w_randomize','w_allow_other','w_allow_other_num','w_choices_params','w_class');
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              if(!isset($param['w_field_option_pos']))
						$param['w_field_option_pos'] = 'left';
						
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");	
              $param['w_choices']	= explode('***',$param['w_choices']);
                 
              $param['w_choices_price']	= explode('***',$param['w_choices_price']);
              
              $param['w_choices_checked']	= explode('***',$param['w_choices_checked']);
                
              if(isset($param['w_choices_params']))
						$param['w_choices_params']	= explode('***',$param['w_choices_params']); 
						
              foreach($param['w_choices_checked'] as $key => $choices_checked )
              {
                if($choices_checked=='true')
                  $param['w_choices_checked'][$key]='checked="checked"';
                else
                  $param['w_choices_checked'][$key]='';
              }
              
              $rep='<div id="wdform_field'.$id.'" type="type_paypal_shipping" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="wd_form_label" style="vertical-align: top;">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required" style="vertical-align: top;">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; vertical-align:top;"><input type="hidden" value="type_paypal_shipping" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_randomize'].'" name="'.$id.'_randomizeform_id_temp" id="'.$id.'_randomizeform_id_temp"><input type="hidden" value="'.$param['w_allow_other'].'" name="'.$id.'_allow_otherform_id_temp" id="'.$id.'_allow_otherform_id_temp"><input type="hidden" value="'.$param['w_allow_other_num'].'" name="'.$id.'_allow_other_numform_id_temp" id="'.$id.'_allow_other_numform_id_temp"><input type="hidden" value="'.$param['w_field_option_pos'].'" id="'.$id.'_option_left_right"><div style="display: table;"><div id="'.$id.'_table_little" style="display: table-row-group;">';
				
				if($param['w_flow']=='hor')
				{
					$rep.= '<div id="'.$id.'_hor" style="display: table-row;">';
					foreach($param['w_choices'] as $key => $choice)
					{
					    $where ='';
						$order_by ='';
						$db_info ='';
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}
						
						$rep.='<div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="radio" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp" value="'.$param['w_choices_price'][$key].'" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div>';
					}
					$rep.= '</div>';
				}
				else
				{
					
					foreach($param['w_choices'] as $key => $choice)
					{
					$where ='';
						$order_by ='';
						$db_info =''; 
						if(isset($param['w_choices_params']) && $param['w_choices_params'][$key])
						{
							$w_choices_params = explode('[where_order_by]',$param['w_choices_params'][$key]);
							$where = "where='".$w_choices_params[0]."'";
							$w_choices_params = explode('[db_info]',$w_choices_params[1]);
							$order_by = "order_by='".$w_choices_params[0]."'";
							$db_info = "db_info='".$w_choices_params[1]."'";
						}
					
						$rep.='<div id="'.$id.'_element_tr'.$key.'" style="display: table-row;"><div valign="top" id="'.$id.'_td_little'.$key.'" idi="'.$key.'" style="display: table-cell;"><input type="radio" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp" value="'.$param['w_choices_price'][$key].'" onclick="set_default(&quot;'.$id.'&quot;,&quot;'.$key.'&quot;,&quot;form_id_temp&quot;)" '.$param['w_choices_checked'][$key].' '.$param['attributes'].' '.($param['w_field_option_pos']=='right' ? 'style="float:left !important;"' : "").' disabled/><label id="'.$id.'_label_element'.$key.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$key.'" '.$where.' '.$order_by.' '.$db_info.'>'.$choice.'</label></div></div>';
					}
					
				}
					$rep.='</div></div>';

					$rep.='</div></div>';
				
					break;
            }
            case 'type_paypal_total':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
            
                    
                      
              $rep='<div id="wdform_field'.$id.'" type="type_paypal_total" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_paypal_total" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><div id="'.$id.'paypal_totalform_id_temp" class="wdform_paypal_total paypal_totalform_id_temp"><input type="hidden" value="" name="'.$id.'_paypal_totalform_id_temp" class="input_paypal_totalform_id_temp"><div id="'.$id.'div_totalform_id_temp" class="div_totalform_id_temp" style="margin-bottom: 10px;"><!--repstart-->$300<!--repend--></div><div id="'.$id.'paypal_productsform_id_temp" class="paypal_productsform_id_temp" style="border-spacing: 2px;"><div style="border-spacing: 2px;"><!--repstart-->product 1 $100<!--repend--></div><div style="border-spacing: 2px;"><!--repstart-->product 2 $200<!--repend--></div></div><div id="'.$id.'paypal_taxform_id_temp" class="paypal_taxform_id_temp" style="border-spacing: 2px; margin-top: 7px;"></div></div></div></div>';
            
            
              break;
            }

            case 'type_star_rating':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_field_label_col','w_star_amount','w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
              
      
            $images = '';	
              for($i=0; $i<$param['w_star_amount']; $i++)
              {
                $images .= '<img id="'.$id.'_star_'.$i.'" src="' . WD_FMC_URL . '/images/star.png?ver='. get_option("wd_form_maker_version").'" onmouseover="change_src('.$i.','.$id.',&quot;form_id_temp&quot;)" onmouseout="reset_src('.$i.','.$id.')" onclick="select_star_rating('.$i.','.$id.', &quot;form_id_temp&quot;)">';
              }
              
              $rep ='<div id="wdform_field'.$id.'" type="type_star_rating" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_star_rating" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_star_amount'].'" id="'.$id.'_star_amountform_id_temp" name="'.$id.'_star_amountform_id_temp"><input type="hidden" value="'.$param['w_field_label_col'].'" name="'.$id.'_star_colorform_id_temp" id="'.$id.'_star_colorform_id_temp"><div id="'.$id.'_elementform_id_temp" class="wdform_stars" '.$param['attributes'].'>'.$images.'</div></div></div>';
              
              
              break;
            }
            case 'type_scale_rating':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_mini_labels','w_scale_amount','w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name )
              {	
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }

              if($temp)
              {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
              
              $w_mini_labels = explode('***',$param['w_mini_labels']);
              
              $numbers = '';	
              for($i=1; $i<=$param['w_scale_amount']; $i++)
              {
                $numbers .= '<div id="'.$id.'_scale_td1_'.$i.'form_id_temp" style="text-align: center; display: table-cell;"><span>'.$i.'</span></div>';
              }
              
                        
              $radio_buttons = '';	
              for($k=1; $k<=$param['w_scale_amount']; $k++)
              {
                $radio_buttons .= '<div id="'.$id.'_scale_td2_'.$k.'form_id_temp" style="display: table-cell;"><input id="'.$id.'_scale_radioform_id_temp_'.$k.'" name="'.$id.'_scale_radioform_id_temp" value="'.$k.'" type="radio"></div>';
              }
              
              $rep ='<div id="wdform_field'.$id.'" type="type_scale_rating" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; vertical-align: top; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_scale_rating" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_scale_amount'].'" id="'.$id.'_scale_amountform_id_temp" name="'.$id.'_scale_amountform_id_temp"><div id="'.$id.'_elementform_id_temp" style="float: left;" '.$param['attributes'].'><label class="mini_label" id="'.$id.'_mini_label_worst" style="position: relative; top: 6px; font-size: 11px; display: inline-table;">'.$w_mini_labels[0].'</label><div id="'.$id.'_scale_tableform_id_temp" style="display: inline-table;"><div id="'.$id.'_scale_tr1form_id_temp" style="display: table-row;">'.$numbers.'</div><div id="'.$id.'_scale_tr2form_id_temp" style="display: table-row;">'.$radio_buttons.'</div></div><label class="mini_label" id="'.$id.'_mini_label_best" style="position: relative; top: 6px; font-size: 11px; display: inline-table;">'.$w_mini_labels[1].'</label></div></div></div>';
                  
              break;
            }
            case 'type_spinner':
            {
              $params_names=array('w_field_label_size','w_field_label_pos','w_field_width','w_field_min_value','w_field_max_value', 'w_field_step', 'w_field_value', 'w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name ) {
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              if($temp) {	
                $temp	=explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr)
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_spinner" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_spinner" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_field_width'].'" name="'.$id.'_spinner_widthform_id_temp" id="'.$id.'_spinner_widthform_id_temp"><input type="hidden" value="'.$param['w_field_min_value'].'" id="'.$id.'_min_valueform_id_temp" name="'.$id.'_min_valueform_id_temp"><input type="hidden" value="'.$param['w_field_max_value'].'" name="'.$id.'_max_valueform_id_temp" id="'.$id.'_max_valueform_id_temp"><input type="hidden" value="'.$param['w_field_step'].'" name="'.$id.'_stepform_id_temp" id="'.$id.'_stepform_id_temp"><input type="" value="'.($param['w_field_value']!= 'null' ? $param['w_field_value'] : '').'" name="'.$id.'_elementform_id_temp" id="'.$id.'_elementform_id_temp" onkeypress="return check_isnum_or_minus(event)" style="width: '.$param['w_field_width'].'px;" '.$param['attributes'].' disabled/></div></div>';
              break;
            }
            case 'type_slider': {
              $params_names=array('w_field_label_size','w_field_label_pos','w_field_width','w_field_min_value','w_field_max_value', 'w_field_value', 'w_required','w_class');
              $temp=$params;
              foreach($params_names as $params_name ) {	
                $temp = explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr) {
                  $param['attributes'] = $param['attributes'] . ' add_' . $attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
              $rep ='<div id="wdform_field'.$id.'" type="type_slider" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; vertical-align: top; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_slider" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_field_width'].'" name="'.$id.'_slider_widthform_id_temp" id="'.$id.'_slider_widthform_id_temp"><input type="hidden" value="'.$param['w_field_min_value'].'" id="'.$id.'_slider_min_valueform_id_temp" name="'.$id.'_slider_min_valueform_id_temp"><input type="hidden" value="'.$param['w_field_max_value'].'" id="'.$id.'_slider_max_valueform_id_temp" name="'.$id.'_slider_max_valueform_id_temp"><input type="hidden" value="'.$param['w_field_value'].'" id="'.$id.'_slider_valueform_id_temp" name="'.$id.'_slider_valueform_id_temp"><div id="'.$id.'_slider_tableform_id_temp"><div><div id="'.$id.'_slider_td1form_id_temp"><div name="'.$id.'_elementform_id_temp" id="'.$id.'_elementform_id_temp" style="width: '.$param['w_field_width'].'px;" '.$param['attributes'].'"></div></div></div><div><div align="left" id="'.$id.'_slider_td2form_id_temp" style="display: inline-table; width: 33.3%; text-align: left;"><span id="'.$id.'_element_minform_id_temp" class="label">'.$param['w_field_min_value'].'</span></div><div align="right" id="'.$id.'_slider_td3form_id_temp" style="display: inline-table; width: 33.3%; text-align: center;"><span id="'.$id.'_element_valueform_id_temp" class="label">'.$param['w_field_value'].'</span></div><div align="right" id="'.$id.'_slider_td4form_id_temp" style="display: inline-table; width: 33.3%; text-align: right;"><span id="'.$id.'_element_maxform_id_temp" class="label">'.$param['w_field_max_value'].'</span></div></div></div></div></div>';
              break;
            }
            case 'type_range': {
              $params_names = array('w_field_label_size','w_field_label_pos','w_field_range_width','w_field_range_step','w_field_value1', 'w_field_value2', 'w_mini_labels', 'w_required','w_class');
              $temp = $params;
              foreach ($params_names as $params_name ) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {	
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);   
                foreach($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
              $w_mini_labels = explode('***',$param['w_mini_labels']);
              $rep ='<div id="wdform_field'.$id.'" type="type_range" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_range" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_field_range_width'].'" name="'.$id.'_range_widthform_id_temp" id="'.$id.'_range_widthform_id_temp"><input type="hidden" value="'.$param['w_field_range_step'].'" name="'.$id.'_range_stepform_id_temp" id="'.$id.'_range_stepform_id_temp"><div id="'.$id.'_elemet_table_littleform_id_temp" style="display: table;"><div style="display: table-row;"><div valign="middle" align="left" style="display: table-cell;"><input type="" value="'.($param['w_field_value1']!= 'null' ? $param['w_field_value1'] : '').'" name="'.$id.'_elementform_id_temp0" id="'.$id.'_elementform_id_temp0" onkeypress="return check_isnum_or_minus(event)" style="width: '.$param['w_field_range_width'].'px;"  '.$param['attributes'].' disabled/></div><div valign="middle" align="left" style="display: table-cell; padding-left: 4px;"><input type="" value="'.($param['w_field_value2']!= 'null' ? $param['w_field_value2'] : '').'" name="'.$id.'_elementform_id_temp1" id="'.$id.'_elementform_id_temp1" onkeypress="return check_isnum_or_minus(event)" style="width: '.$param['w_field_range_width'].'px;" '.$param['attributes'].' disabled/></div></div><div style="display: table-row;"><div valign="top" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_from">'.$w_mini_labels[0].'</label></div><div valign="top" align="left" style="display: table-cell;"><label class="mini_label" id="'.$id.'_mini_label_to">'.$w_mini_labels[1].'</label></div></div></div></div></div>';
              break;
            }
            case 'type_grading': {
              $params_names = array('w_field_label_size', 'w_field_label_pos', 'w_items', 'w_total', 'w_required', 'w_class');
              $temp = $params;
              foreach($params_names as $params_name) {
                $temp = explode('*:*' . $params_name . '*:*', $temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {	
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs	= array_slice($temp, 0, count($temp) - 1);   
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos'] == "left" ? "table-cell" : "block");
              $required_sym = ($param['w_required'] == "yes" ? " *" : "");
              $w_items = explode('***', $param['w_items']);
              $grading_items = '';
              for($i=0; $i<count($w_items); $i++)
					{
						$grading_items .= '<div id="'.$id.'_element_div'.$i.'" class="grading"><input id="'.$id.'_elementform_id_temp_'.$i.'" name="'.$id.'_elementform_id_temp_'.$i.'" onkeypress="return check_isnum_or_minus(event)" value="" size="5" onkeyup="sum_grading_values('.$id.',&quot;form_id_temp&quot;)" onchange="sum_grading_values('.$id.',&quot;form_id_temp&quot;)" '.$param['attributes'].' disabled/><label id="'.$id.'_label_elementform_id_temp'.$i.'" class="ch-rad-label">'.$w_items[$i].'</label></div>';
					}
									
					$rep ='<div id="wdform_field'.$id.'" type="type_grading" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; vertical-align: top; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_grading" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_total'].'" name="'.$id.'_grading_totalform_id_temp" id="'.$id.'_grading_totalform_id_temp"><div id="'.$id.'_elementform_id_temp">'.$grading_items.'<div id="'.$id.'_element_total_divform_id_temp" class="grading_div">Total:<span id="'.$id.'_sum_elementform_id_temp" name="'.$id.'_sum_elementform_id_temp">0</span>/<span id="'.$id.'_total_elementform_id_temp" name="'.$id.'_total_elementform_id_temp">'.$param['w_total'].'</span><span id="'.$id.'_text_elementform_id_temp" name="'.$id.'_text_elementform_id_temp"></span></div></div></div></div>';
											
					break;
            }
            case 'type_matrix': {
              $params_names=array('w_field_label_size','w_field_label_pos', 'w_field_input_type', 'w_rows', 'w_columns', 'w_required','w_class','w_textbox_size');
              $temp = $params;
              foreach ($params_names as $params_name) {
                $temp = explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp = $temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*', $temp);
                $attrs = array_slice($temp, 0, count($temp) - 1);
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
              }
              $param['w_field_label_pos'] = ($param['w_field_label_pos']=="left" ? "table-cell" : "block");	
              $required_sym = ($param['w_required']=="yes" ? " *" : "");
			  $param['w_textbox_size'] = isset($param['w_textbox_size']) ? $param['w_textbox_size'] : '100';
              $w_rows = explode('***',$param['w_rows']);
              $w_columns = explode('***',$param['w_columns']);
              $column_labels = '';
              for ($i = 1; $i < count($w_columns); $i++) {
                $column_labels .= '<div id="'.$id.'_element_td0_'.$i.'" class="matrix_" style="display: table-cell;"><label id="'.$id.'_label_elementform_id_temp0_'.$i.'" name="'.$id.'_label_elementform_id_temp0_'.$i.'" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$i.'" value="'.$w_columns[$i].'">'.$w_columns[$i].'</label></div>';
              }
              $rows_columns = '';
              for($i=1; $i<count($w_rows); $i++)
					{
					
						$rows_columns .= '<div id="'.$id.'_element_tr'.$i.'" style="display: table-row;"><div id="'.$id.'_element_td'.$i.'_0" class="matrix_" style="display: table-cell;"><label id="'.$id.'_label_elementform_id_temp'.$i.'_0" class="ch-rad-label" for="'.$id.'_elementform_id_temp'.$i.'" value="'.$w_rows[$i].'">'.$w_rows[$i].'</label></div>';
						
						
						for($k=1; $k<count($w_columns); $k++)
						{
							if($param['w_field_input_type']=='radio')
								$rows_columns .= '<div id="'.$id.'_element_td'.$i.'_'.$k.'" style="text-align: center; display: table-cell;  padding: 5px 0 0 5px;"><input id="'.$id.'_input_elementform_id_temp'.$i.'_'.$k.'" align="center" size="14" type="radio" name="'.$id.'_input_elementform_id_temp'.$i.'" value="'.$i.'_'.$k.'" disabled/></div>';
							else
								if($param['w_field_input_type']=='checkbox')
									$rows_columns .= '<div id="'.$id.'_element_td'.$i.'_'.$k.'" style="text-align: center; display: table-cell;  padding: 5px 0 0 5px;"><input id="'.$id.'_input_elementform_id_temp'.$i.'_'.$k.'" align="center" size="14" type="checkbox" name="'.$id.'_input_elementform_id_temp'.$i.'_'.$k.'" value="1" disabled/></div>';
								else
									if($param['w_field_input_type']=='text')
										$rows_columns .= '<div id="'.$id.'_element_td'.$i.'_'.$k.'" style="text-align: center; display: table-cell; padding: 5px 0 0 5px;"><input id="'.$id.'_input_elementform_id_temp'.$i.'_'.$k.'" align="center" type="text" name="'.$id.'_input_elementform_id_temp'.$i.'_'.$k.'" value="" style="width:'.$param['w_textbox_size'].'px" disabled/></div>';
									else
										if($param['w_field_input_type']=='select')
											$rows_columns .= '<div id="'.$id.'_element_td'.$i.'_'.$k.'" style="text-align: center; display: table-cell; padding: 5px 0 0 5px;"><select id="'.$id.'_select_yes_noform_id_temp'.$i.'_'.$k.'" name="'.$id.'_select_yes_noform_id_temp'.$i.'_'.$k.'" disabled><option value=""> </option><option value="yes">Yes</option><option value="no">No</option></select></div>';
								
						}
							
						$rows_columns .= '</div>';	
					}
						
					
						
					$rep ='<div id="wdform_field'.$id.'" type="type_matrix" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].'; width: '.$param['w_field_label_size'].'px;"><span id="'.$id.'_element_labelform_id_temp" class="label">'.$label.'</span><span id="'.$id.'_required_elementform_id_temp" class="required">'.$required_sym.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: '.$param['w_field_label_pos'].';"><input type="hidden" value="type_matrix" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><input type="hidden" value="'.$param['w_required'].'" name="'.$id.'_requiredform_id_temp" id="'.$id.'_requiredform_id_temp"><input type="hidden" value="'.$param['w_field_input_type'].'" name="'.$id.'_input_typeform_id_temp" id="'.$id.'_input_typeform_id_temp"><input type="hidden" value="'.$param['w_textbox_size'].'" name="'.$id.'_textbox_sizeform_id_temp" id="'.$id.'_textbox_sizeform_id_temp"><div id="'.$id.'_elementform_id_temp" style="display: table;" '.$param['attributes'].'><div id="'.$id.'_table_little" style="display: table-row-group;"><div id="'.$id.'_element_tr0" style="display: table-row;"><div id="'.$id.'_element_td0_0" style="display: table-cell;"></div>'.$column_labels.'</div>'.$rows_columns.'</div></div></div></div>';
											
					break;
            }
            case 'type_submit_reset': {
              $params_names=array('w_submit_title','w_reset_title','w_class','w_act');
              $temp=$params;
              foreach ($params_names as $params_name) {
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              if ($temp) {
                $temp	= explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach ($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
              }
              $param['w_act'] = ($param['w_act']=="false" ? 'style="display: none;"' : "");	
              $rep='<div id="wdform_field'.$id.'" type="type_submit_reset" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><span id="'.$id.'_element_labelform_id_temp" style="display: none;">type_submit_reset_'.$id.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><input type="hidden" value="type_submit_reset" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp"><button type="button" class="button-submit" id="'.$id.'_element_submitform_id_temp" value="'.$param['w_submit_title'].'" onclick="check_required(&quot;submit&quot;, &quot;form_id_temp&quot;);" '.$param['attributes'].'>'.$param['w_submit_title'].'</button><button type="button" class="button-reset" id="'.$id.'_element_resetform_id_temp" value="'.$param['w_reset_title'].'" onclick="check_required(&quot;reset&quot;);" '.$param['w_act'].' '.$param['attributes'].'>'.$param['w_reset_title'].'</button></div></div>';
              break;
            }
            case 'type_button': {
              $params_names=array('w_title','w_func','w_class');
              $temp=$params;
              foreach($params_names as $params_name) {
                $temp=explode('*:*'.$params_name.'*:*',$temp);
                $param[$params_name] = $temp[0];
                $temp=$temp[1];
              }
              if ($temp) {	
                $temp	= explode('*:*w_attr_name*:*',$temp);
                $attrs	= array_slice($temp,0, count($temp)-1);   
                foreach($attrs as $attr) {
                  $param['attributes'] = $param['attributes'].' add_'.$attr;
                }
              }
              $param['w_title']	= explode('***',$param['w_title']);
              $param['w_func']	= explode('***',$param['w_func']);
              $rep.='<div id="wdform_field'.$id.'" type="type_button" class="wdform_field" style="display: table-cell;">'.$arrows.'<div align="left" id="'.$id.'_label_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><span id="'.$id.'_element_labelform_id_temp" style="display: none;">button_'.$id.'</span></div><div align="left" id="'.$id.'_element_sectionform_id_temp" class="'.$param['w_class'].'" style="display: table-cell;"><input type="hidden" value="type_button" name="'.$id.'_typeform_id_temp" id="'.$id.'_typeform_id_temp">';
              foreach ($param['w_title'] as $key => $title) {
                $rep.='<button type="button" id="'.$id.'_elementform_id_temp'.$key.'" name="'.$id.'_elementform_id_temp'.$key.'" value="'.$title.'" onclick="'.$param['w_func'][$key].'" '.$param['attributes'].'>'.$title.'</button>';				
              }
              $rep .= '</div></div>';
              break;
            }
          }
          
          $form = str_replace('%' . $id . ' - ' . $labels[$ids_key] . '%', $rep, $form);
          $form = str_replace('%' . $id . ' -' . $labels[$ids_key] . '%', $rep, $form);
          $row->form_front = $form;
        }
      }
    }
    else {
      $row = new stdClass();
      $row->id = 0;
      $row->backup_id ='';
      $row->title = '';
      $row->mail = '';
      $row->form = '';
      $row->form_front = '';
      $row->theme = $wpdb->get_var("SELECT id FROM " . $wpdb->prefix . "formmaker_themes WHERE `default`='1'");
      $row->javascript = '';
      $row->submit_text = '';
      $row->url = '';
      $row->submit_text_type = 0;
      $row->script1 = '';
      $row->script2 = '';
      $row->script_user1 = '';
      $row->script_user2 = '';
      $row->counter = 0;
      $row->label_order = '';
      $row->article_id = '';
      $row->pagination = '';
      $row->show_title = '';
      $row->show_numbers = '';
      $row->public_key = '';
      $row->private_key = '';
      $row->recaptcha_theme = '';
      $row->from_name = '';
      $row->from_mail = '';
      $row->label_order_current = '';
      $row->script_mail_user = '';
      $row->script_mail = '';
      $row->tax = 0;
      $row->payment_currency = '$';
      $row->paypal_email = '';
      $row->checkout_mode = 'testmode';
      $row->paypal_mode = 0;

      $row->published = 1;
      $row->form_fields = '';
      $row->savedb = 1;
      $row->sendemail = 1;
      $row->requiredmark = '*';
      $row->reply_to = 0;
      $row->send_to = 0;
      $row->autogen_layout = 1;
      $row->custom_front = '';
      $row->mail_from_user = '';
      $row->mail_from_name_user = '';
      $row->reply_to_user = '';
      $row->save_uploads = 1;

      $row->condition = '';
      $row->mail_cc = '';
      $row->mail_cc_user = '';
      $row->mail_bcc = '';
      $row->mail_bcc_user = '';
      $row->mail_subject = '';
      $row->mail_subject_user = '';
      $row->mail_mode = 1;
      $row->mail_mode_user = 1;
      $row->mail_attachment = 1;
      $row->mail_attachment_user = 1;
      
      $row->user_id_wd = '';
      $row->sortable = 1;
      $row->frontend_submit_fields = '';
      $row->frontend_submit_stat_fields = '';
    }
    return $row;
  }

  public function get_theme_rows_data($old = '') {
    global $wpdb;
    $rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "formmaker_themes WHERE css " . ($old ? 'NOT' : '') . " LIKE '%.wdform_section%' ORDER BY title");
    return $rows;
  }
  
  public function get_queries_rows_data($id) {
    global $wpdb;
    $rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "formmaker_query WHERE form_id=" . $id . " ORDER BY id ASC");
    return $rows;
  }
  
  public function get_labels($id) {
    global $wpdb;
    $rows = $wpdb->get_col("SELECT DISTINCT `element_label` FROM " . $wpdb->prefix . "formmaker_submits WHERE form_id=" . $id);
    return $rows;
  }
  
  public function is_paypal($id) {
    global $wpdb;
    $rows = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker_sessions WHERE form_id=" . $id);
    return $rows;
  }

  public function page_nav() {
    global $wpdb;
	$where = 'WHERE `id` IN (' . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ')';
    $where .= ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE title LIKE "%' . esc_html($_POST['search_value']) . '%"'  : '');
    $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker " . $where;
    $total = $wpdb->get_var($query);
    $page_nav['total'] = $total;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $page_nav['limit'] = (int) ($limit / 20 + 1);
    return $page_nav;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFromeditcountryinpopup_fmc.php000060400000004341152435511120015376 0ustar00<?php

class FMModelFromeditcountryinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelUninstall_fmc.php000060400000007775152435511120012555 0ustar00<?php

class FMModelUninstall_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function delete_db_tables() {
    global $wpdb;
    $true_or_false_forms = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker WHERE `id` IN (" . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ")");
    if ($true_or_false_forms) {
      $wpdb->query("DELETE FROM " . $wpdb->prefix . "formmaker WHERE `id` NOT IN (" . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ")");
      $wpdb->query("DELETE FROM " . $wpdb->prefix . "formmaker_submits WHERE `form_id` NOT IN (" . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ")");
      $wpdb->query("DELETE FROM " . $wpdb->prefix . "formmaker_views WHERE `form_id` NOT IN (" . (get_option('contact_form_forms', '') != '' ? get_option('contact_form_forms') : 0) . ")");
	  delete_option('contact_form_forms');
    }
    else {
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_submits");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_views");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_themes");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_sessions");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_blocked");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_query");
      $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "formmaker_backup");
	  delete_option('contact_form_forms');
      delete_option("wd_form_maker_version");
      delete_option('formmaker_cureent_version');
      delete_option('fm_emailverification');
      delete_option('form_maker_pro_active');
	  
    }
	delete_option('fmc_settings');
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/.htaccess000044400000000424152435511120007622 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>models/FMModelFormcontactwdmathcaptcha.php000060400000004337152435511120014756 0ustar00<?php

class FMModelFormcontactwdmathcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFormcontactwdcaptcha.php000060400000004333152435511120014100 0ustar00<?php

class FMModelFormcontactwdcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelBlocked_ips_fmc.php000060400000007767152435511120013023 0ustar00<?php

class FMModelBlocked_ips_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function get_rows_data() {
    global $wpdb;
    $where = ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE `ip` LIKE "%' . esc_html($_POST['search_value']) . '%"' : '');
    $asc_or_desc = ((isset($_POST['asc_or_desc']) && $_POST['asc_or_desc'] == 'desc') ? 'desc' : 'asc');
	$order_by_array = array('id', 'ip');
    $order_by = isset($_POST['order_by']) && in_array(esc_html(stripslashes($_POST['order_by'])), $order_by_array) ? esc_html(stripslashes($_POST['order_by'])) :  'id';
    $order_by = ' ORDER BY `' . $order_by . '` ' . $asc_or_desc;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker_blocked " . $where . $order_by . " LIMIT " . $limit . ",20";
    $rows = $wpdb->get_results($query);
    return $rows;
  }
  
  public function get_row_data($id) {
    global $wpdb;
    if ($id != 0) {
      $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE id="%d"', $id));
    }
    else {
      $row->id = 0;
      $row->ip = '';
    }
    return $row;
  }

  public function page_nav() {
    global $wpdb;
    $where = ((isset($_POST['search_value']) && (esc_html($_POST['search_value']) != '')) ? 'WHERE `ip` LIKE "%' . esc_html($_POST['search_value']) . '%"'  : '');
    $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker_blocked " . $where;
    $total = $wpdb->get_var($query);
    $page_nav['total'] = $total;
    if (isset($_POST['page_number']) && $_POST['page_number']) {
      $limit = ((int) $_POST['page_number'] - 1) * 20;
    }
    else {
      $limit = 0;
    }
    $page_nav['limit'] = (int) ($limit / 20 + 1);
    return $page_nav;
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelLicensing_fmc.php000060400000004323152435511120012501 0ustar00<?php

class FMModelLicensing_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelGenerete_csv_fmc.php000060400000030443152435511120013201 0ustar00<?php

class FMModelGenerete_csv_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
	public function get_data() {
		global $wpdb;
		$is_paypal_info = FALSE;
		$params = array();
		$group_id_s = array();
		$form_id = (int)$_REQUEST['form_id'];
		$limitstart = (int)$_REQUEST['limitstart'];
			
		$paypal_info_fields = array('currency', 'ord_last_modified', 'status', 'full_name', 'fax', 'mobile_phone', 'email', 'phone', 'address', 'paypal_info',  'ipn', 'tax', 'shipping');
		$paypal_info_labels = array( 'Currency', 'Last modified', 'Status', 'Full Name', 'Fax', 'Mobile phone', 'Email', 'Phone', 'Address', 'Paypal info', 'IPN', 'Tax', 'Shipping');
		
		$query = $wpdb->prepare("SELECT distinct group_id FROM " . $wpdb->prefix . "formmaker_submits where form_id=%d", $form_id);		
		$group_id_s = $wpdb->get_col($query);	

		$query = $wpdb->prepare("SELECT distinct element_label FROM " . $wpdb->prefix . "formmaker_submits where form_id=%d",$form_id);	
		$labels = $wpdb->get_col($query);
		
		$query_lable = $wpdb->prepare("SELECT label_order,title FROM " . $wpdb->prefix . "formmaker where id=%d", $form_id);
		$rows_lable = $wpdb->get_results($query_lable);
		$ptn = "/[^a-zA-Z0-9_]/";
		$rpltxt = "";
		$title = isset($rows_lable[0]) ? preg_replace($ptn, $rpltxt, $rows_lable[0]->title) : '';
		
		$sorted_labels_id = array();
		$sorted_labels = array();
		$label_titles = array();
		$label_id = array();
		$label_order = array();
		$label_order_original = array();
		$label_type = array();
		if ($labels) {
			$label_all = explode('#****#', $rows_lable[0]->label_order);
			$label_all = array_slice($label_all, 0, count($label_all) - 1);
			foreach ($label_all as $key => $label_each) {
				$label_id_each = explode('#**id**#', $label_each);
				array_push($label_id, $label_id_each[0]);
				$label_oder_each = explode('#**label**#', $label_id_each[1]);
				array_push($label_order_original, $label_oder_each[0]);
				$label_temp = preg_replace($ptn, $rpltxt, $label_oder_each[0]);
				array_push($label_order, $label_temp);
				array_push($label_type, $label_oder_each[1]);
			}
			foreach ($label_id as $key => $label) {
				if (in_array($label, $labels) && $label_type[$key] !='type_arithmetic_captcha') {
					array_push($sorted_labels, $label_order[$key]);
					array_push($sorted_labels_id, $label);
					array_push($label_titles, stripslashes($label_order_original[$key]));
				}
			}
		}

		$m = count($sorted_labels);
		$wpdb->query("SET SESSION group_concat_max_len = 1000000");
		
		$query = $wpdb->prepare("SELECT group_id, ip, date, user_id_wd, GROUP_CONCAT( element_label SEPARATOR ',') as element_label, GROUP_CONCAT( element_value SEPARATOR '*:*el_value*:*') as element_value FROM " . $wpdb->prefix . "formmaker_submits where form_id= %d GROUP BY group_id ORDER BY date ASC limit %d, %d", $form_id, $limitstart, 1000);
		$rows = $wpdb->get_results($query, OBJECT_K);

		$data = array();
		$group_id_s_count = $limitstart + 1000 < count($group_id_s) ? $limitstart + 1000 : count($group_id_s);

		for ($www = $limitstart; $www < $group_id_s_count; $www++) {
			$i = $group_id_s[$www];
			$field_key = array_search($i, $label_id);
			if($label_type[$field_key] != 'type_arithmetic_captcha') {
				$data_temp = array();
				$tt = $rows[$i];

				$date = $tt->date;
				$ip = $tt->ip;
				$user_id = get_userdata($tt->user_id_wd);
				$username = $user_id ? $user_id->display_name : "";
				$useremail = $user_id ? $user_id->user_email : "";
				$data_temp['Submit date'] = $date;
				$data_temp['Ip']=$ip;
				$data_temp['Submitter\'s Username']=$username;
				$data_temp['Submitter\'s Email Address']=$useremail;
			
				$element_labels = explode(',', $tt->element_label);
				$element_values = explode('*:*el_value*:*', $tt->element_value);
				for ($h = 0; $h < $m; $h++) {
					if(isset($data_temp[$label_titles[$h]]))
						$label_titles[$h] .= '(1)';
					
					if(in_array($sorted_labels_id[$h], $element_labels)) {
						$element_value = $element_values[array_search($sorted_labels_id[$h], $element_labels)];
				
						if (strpos($element_value, "*@@url@@*")) {
							$file_names = '';
							$new_files = explode("*@@url@@*", $element_value);
							foreach ($new_files as $new_file) {
								if ($new_file) {
									$file_names .= $new_file . ", ";
								}
							}
							$data_temp[stripslashes($label_titles[$h])] = $file_names;
						}
						elseif (strpos($element_value, "***br***")) {
							$element_value = str_replace("***br***", ', ', $element_value);
							if (strpos($element_value, "***quantity***")) {
								$element_value = str_replace("***quantity***", '', $element_value);
							}
							if (strpos($element_value, "***property***")) {
								$element_value = str_replace("***property***", '', $element_value);
							}
							if(substr($element_value, -2) == ', ') {
								$data_temp[stripslashes($label_titles[$h])]= substr($element_value, 0, -2);
							}
							else {
								$data_temp[stripslashes($label_titles[$h])]= $element_value;
							}
						}
						elseif (strpos($element_value, "***map***")) {
							$data_temp[stripslashes($label_titles[$h])] = 'Longitude:' . str_replace("***map***", ', Latitude:', $element_value);
						}
						elseif (strpos($element_value, "***star_rating***")) {
							$element = str_replace("***star_rating***", '', $element_value);
							$element = explode("***", $element);
							$data_temp[stripslashes($label_titles[$h])] = ' ' . $element[1] . '/' . $element[0];
						}
						elseif (strpos($element_value, "@@@") || $element_value == "@@@" || $element_value == "@@@@@@@@@") {
							$data_temp[stripslashes($label_titles[$h])] = str_replace("@@@", ' ', $element_value);
						}
						elseif (strpos($element_value, "***grading***")) {
							$element = str_replace("***grading***", '', $element_value);
							$grading = explode(":", $element);
							$items_count = sizeof($grading) - 1;
							$items = "";
							$total = "";
							for ($k = 0; $k < $items_count / 2; $k++) {
								$items .= $grading[$items_count / 2 + $k] . ": " . $grading[$k] . ", ";
								$total += $grading[$k];
							}
							$items .= "Total: " . $total;
								$data_temp[stripslashes($label_titles[$h])] = $items;
						}
						elseif (strpos($element_value, "***matrix***")) {
							$element = str_replace("***matrix***", '', $element_value);
							$matrix_value = explode('***', $element);
							$matrix_value = array_slice($matrix_value, 0, count($matrix_value) - 1);
							$mat_rows = $matrix_value[0];
							$mat_columns = $matrix_value[$mat_rows + 1];
							$matrix = "";
							$aaa = array();
							$var_checkbox = 1;
							$selected_value = "";
							$selected_value_yes = "";
							$selected_value_no = "";
							for ($k = 1; $k <= $mat_rows; $k++) {
								if ($matrix_value[$mat_rows + $mat_columns + 2] == "radio") {
									if ($matrix_value[$mat_rows + $mat_columns + 2 + $k] == 0) {
										$checked = "0";
										$aaa[1] = "";
									}
									else {
										$aaa = explode("_", $matrix_value[$mat_rows + $mat_columns + 2 + $k]);
									}
									for ($l = 1; $l <= $mat_columns; $l++) {
										$checked = $aaa[1] == $l ? '1' : '0';
										$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$checked."; ";
									}
								}
								else {
									if ($matrix_value[$mat_rows+$mat_columns + 2] == "checkbox") {
										for ($l = 1; $l <= $mat_columns; $l++) {
											$checked = $matrix_value[$mat_rows+$mat_columns + 2 + $var_checkbox] == 1 ? '1' : '0';
											$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$checked."; ";
											$var_checkbox++;
										}
									}
									else {
										if ($matrix_value[$mat_rows+$mat_columns + 2] == "text") {
											for ($l = 1; $l <= $mat_columns; $l++) {
												$text_value = $matrix_value[$mat_rows+$mat_columns+2+$var_checkbox];
												$matrix .='['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$text_value."; ";
												$var_checkbox++;
											}
										}
										else {
											for ($l = 1; $l <= $mat_columns; $l++) {
												$selected_text = $matrix_value[$mat_rows+$mat_columns + 2 + $var_checkbox];
												$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows + 1 + $l].']='.$selected_text."; ";
												$var_checkbox++;
											}
										}
									}
								}
							}
							$data_temp[stripslashes($label_titles[$h])] = $matrix;
						}
						else {
							$val = htmlspecialchars_decode($element_value);
							$val = stripslashes(str_replace('&#039;', "'", $val));
							$data_temp[stripslashes($label_titles[$h])] = ($element_value ? $val : '');
						}
					}
					else						
						$data_temp[stripslashes($label_titles[$h])] = '';
				}
			
				$query = $wpdb->prepare("SELECT id FROM " . $wpdb->prefix . "formmaker_submits where element_label=%s AND form_id = %d AND group_id=%d",'item_total', $form_id, $i);	
				$is_paypal = $wpdb->get_results($query);
			
				if($is_paypal) {
					$item_total = $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s", $i, 'item_total'));        
					$total = $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s", $i, 'total'));        
					$payment_status = $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s", $i, '0'));        
					$data_temp['Item Total'] = $item_total;
					$data_temp['Total'] = $total;
					$data_temp['Payment Status'] = $payment_status;
				}
				$query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "formmaker_sessions where group_id=%d",$i);
				$paypal_info = $wpdb->get_results($query);
				if ($paypal_info) {
					$is_paypal_info = TRUE;
				}
				if ($is_paypal) {
					foreach ($paypal_info_fields as $key=>$paypal_info_field) {
						if ($paypal_info) {
							$data_temp['PAYPAL_'.$paypal_info_labels[$key]]=$paypal_info[0]->$paypal_info_field;
						}
						else {
							$data_temp['PAYPAL_'.$paypal_info_labels[$key]]='';
						}
					}
				}
				
				$data[$i] = $data_temp;
			} 
		}

		array_push($params, $data);
		array_push($params, $title);
		array_push($params, $is_paypal_info);

		return $params;	

	}
  
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelFormMakerEditCSS_fmc.php000060400000005146152435511120013634 0ustar00<?php

class FMModelFormMakerEditCSS_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function get_theme_row($id) {
    global $wpdb;
    $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $id));
    return $row;
  }

  /*public function get_form($form_id) {
    global $wpdb;
    $form = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $form_id));
    return $form;
  }*/
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}models/FMModelGenerete_xml_fmc.php000060400000030107152435511120013203 0ustar00<?php

class FMModelGenerete_xml_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function get_data() {
		global $wpdb;
		$is_paypal_info = FALSE;
		$params = array();
		$group_id_s = array();
		$form_id = (int)$_REQUEST['form_id'];
		$limitstart = (int)$_REQUEST['limitstart'];
			
		$paypal_info_fields = array('currency', 'ord_last_modified', 'status', 'full_name', 'fax', 'mobile_phone', 'email', 'phone', 'address', 'paypal_info',  'ipn', 'tax', 'shipping');
		$paypal_info_labels = array( 'Currency', 'Last modified', 'Status', 'Full Name', 'Fax', 'Mobile phone', 'Email', 'Phone', 'Address', 'Paypal info', 'IPN', 'Tax', 'Shipping');
		
		$query = $wpdb->prepare("SELECT distinct group_id FROM " . $wpdb->prefix . "formmaker_submits where form_id=%d", $form_id);		
		$group_id_s = $wpdb->get_col($query);	

		$query = $wpdb->prepare("SELECT distinct element_label FROM " . $wpdb->prefix . "formmaker_submits where form_id=%d",$form_id);	
		$labels = $wpdb->get_col($query);
		
		$query_lable = $wpdb->prepare("SELECT label_order,title FROM " . $wpdb->prefix . "formmaker where id=%d", $form_id);
		$rows_lable = $wpdb->get_results($query_lable);
		$ptn = "/[^a-zA-Z0-9_]/";
		$rpltxt = "";
		$title = isset($rows_lable[0]) ? preg_replace($ptn, $rpltxt, $rows_lable[0]->title) : '';
		
		$sorted_labels_id = array();
		$sorted_labels = array();
		$label_titles = array();
		$label_id = array();
		$label_order = array();
		$label_order_original = array();
		$label_type = array();
		if ($labels) {
			$label_all = explode('#****#', $rows_lable[0]->label_order);
			$label_all = array_slice($label_all, 0, count($label_all) - 1);
			foreach ($label_all as $key => $label_each) {
				$label_id_each = explode('#**id**#', $label_each);
				array_push($label_id, $label_id_each[0]);
				$label_oder_each = explode('#**label**#', $label_id_each[1]);
				array_push($label_order_original, $label_oder_each[0]);
				$label_temp = preg_replace($ptn, $rpltxt, $label_oder_each[0]);
				array_push($label_order, $label_temp);
				array_push($label_type, $label_oder_each[1]);
			}
			foreach ($label_id as $key => $label) {
				if (in_array($label, $labels) && $label_type[$key] !='type_arithmetic_captcha') {
					array_push($sorted_labels, $label_order[$key]);
					array_push($sorted_labels_id, $label);
					array_push($label_titles, stripslashes($label_order_original[$key]));
				}
			}
		}

		$m = count($sorted_labels);
		
		$query = $wpdb->prepare("SELECT group_id, ip, date, user_id_wd, GROUP_CONCAT( element_label SEPARATOR ',') as element_label, GROUP_CONCAT( element_value SEPARATOR '*:*el_value*:*') as element_value FROM " . $wpdb->prefix . "formmaker_submits where form_id= %d GROUP BY group_id ORDER BY date ASC limit %d, %d", $form_id, $limitstart, 1000);
		$rows = $wpdb->get_results($query, OBJECT_K);

		$data = array();
		$group_id_s_count = $limitstart + 1000 < count($group_id_s) ? $limitstart + 1000 : count($group_id_s);

		for ($www = $limitstart; $www < $group_id_s_count; $www++) {
			$i = $group_id_s[$www];
			$field_key = array_search($i, $label_id);
			if($label_type[$field_key] != 'type_arithmetic_captcha') {
				$data_temp = array();
				$tt = $rows[$i];

				$date = $tt->date;
				$ip = $tt->ip;
				$user_id = get_userdata($tt->user_id_wd);
				$username = $user_id ? $user_id->display_name : "";
				$useremail = $user_id ? $user_id->user_email : "";
				$data_temp['Submit date'] = $date;
				$data_temp['Ip']=$ip;
				$data_temp['Submitter\'s Username']=$username;
				$data_temp['Submitter\'s Email Address']=$useremail;
			
				$element_labels = explode(',', $tt->element_label);
				$element_values = explode('*:*el_value*:*', $tt->element_value);
				for ($h = 0; $h < $m; $h++) {
					if(isset($data_temp[$label_titles[$h]]))
						$label_titles[$h] .= '(1)';
					
					if(in_array($sorted_labels_id[$h], $element_labels)) {
						$element_value = $element_values[array_search($sorted_labels_id[$h], $element_labels)];
				
						if (strpos($element_value, "*@@url@@*")) {
							$file_names = '';
							$new_files = explode("*@@url@@*", $element_value);
							foreach ($new_files as $new_file) {
								if ($new_file) {
									$file_names .= $new_file . ", ";
								}
							}
							$data_temp[stripslashes($label_titles[$h])] = $file_names;
						}
						elseif (strpos($element_value, "***br***")) {
							$element_value = str_replace("***br***", ', ', $element_value);
							if (strpos($element_value, "***quantity***")) {
								$element_value = str_replace("***quantity***", '', $element_value);
							}
							if (strpos($element_value, "***property***")) {
								$element_value = str_replace("***property***", '', $element_value);
							}
							if(substr($element_value, -2) == ', ') {
								$data_temp[stripslashes($label_titles[$h])]= substr($element_value, 0, -2);
							}
							else {
								$data_temp[stripslashes($label_titles[$h])]= $element_value;
							}
						}
						elseif (strpos($element_value, "***map***")) {
							$data_temp[stripslashes($label_titles[$h])] = 'Longitude:' . str_replace("***map***", ', Latitude:', $element_value);
						}
						elseif (strpos($element_value, "***star_rating***")) {
							$element = str_replace("***star_rating***", '', $element_value);
							$element = explode("***", $element);
							$data_temp[stripslashes($label_titles[$h])] = ' ' . $element[1] . '/' . $element[0];
						}
						elseif (strpos($element_value, "@@@") || $element_value == "@@@" || $element_value == "@@@@@@@@@") {
							$data_temp[stripslashes($label_titles[$h])] = str_replace("@@@", ' ', $element_value);
						}
						elseif (strpos($element_value, "***grading***")) {
							$element = str_replace("***grading***", '', $element_value);
							$grading = explode(":", $element);
							$items_count = sizeof($grading) - 1;
							$items = "";
							$total = "";
							for ($k = 0; $k < $items_count / 2; $k++) {
								$items .= $grading[$items_count / 2 + $k] . ": " . $grading[$k] . ", ";
								$total += $grading[$k];
							}
							$items .= "Total: " . $total;
								$data_temp[stripslashes($label_titles[$h])] = $items;
						}
						elseif (strpos($element_value, "***matrix***")) {
							$element = str_replace("***matrix***", '', $element_value);
							$matrix_value = explode('***', $element);
							$matrix_value = array_slice($matrix_value, 0, count($matrix_value) - 1);
							$mat_rows = $matrix_value[0];
							$mat_columns = $matrix_value[$mat_rows + 1];
							$matrix = "";
							$aaa = array();
							$var_checkbox = 1;
							$selected_value = "";
							$selected_value_yes = "";
							$selected_value_no = "";
							for ($k = 1; $k <= $mat_rows; $k++) {
								if ($matrix_value[$mat_rows + $mat_columns + 2] == "radio") {
									if ($matrix_value[$mat_rows + $mat_columns + 2 + $k] == 0) {
										$checked = "0";
										$aaa[1] = "";
									}
									else {
										$aaa = explode("_", $matrix_value[$mat_rows + $mat_columns + 2 + $k]);
									}
									for ($l = 1; $l <= $mat_columns; $l++) {
										$checked = $aaa[1] == $l ? '1' : '0';
										$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$checked."; ";
									}
								}
								else {
									if ($matrix_value[$mat_rows+$mat_columns + 2] == "checkbox") {
										for ($l = 1; $l <= $mat_columns; $l++) {
											$checked = $matrix_value[$mat_rows+$mat_columns + 2 + $var_checkbox] == 1 ? '1' : '0';
											$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$checked."; ";
											$var_checkbox++;
										}
									}
									else {
										if ($matrix_value[$mat_rows+$mat_columns + 2] == "text") {
											for ($l = 1; $l <= $mat_columns; $l++) {
												$text_value = $matrix_value[$mat_rows+$mat_columns+2+$var_checkbox];
												$matrix .='['.$matrix_value[$k].','.$matrix_value[$mat_rows+1+$l].']='.$text_value."; ";
												$var_checkbox++;
											}
										}
										else {
											for ($l = 1; $l <= $mat_columns; $l++) {
												$selected_text = $matrix_value[$mat_rows+$mat_columns + 2 + $var_checkbox];
												$matrix .= '['.$matrix_value[$k].','.$matrix_value[$mat_rows + 1 + $l].']='.$selected_text."; ";
												$var_checkbox++;
											}
										}
									}
								}
							}
							$data_temp[stripslashes($label_titles[$h])] = $matrix;
						}
						else {
							$val = htmlspecialchars_decode($element_value);
							$val = stripslashes(str_replace('&#039;', "'", $val));
							$data_temp[stripslashes($label_titles[$h])] = ($element_value ? $val : '');
						}
					}
					else						
						$data_temp[stripslashes($label_titles[$h])] = '';
				}
			
				$item_total = $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s",$i,'item_total'));
		
				$total = $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s",$i,'total'));
			
				$payment_status =   $wpdb->get_var($wpdb->prepare("SELECT `element_value` FROM " . $wpdb->prefix . "formmaker_submits where group_id=%d AND element_label=%s",$i,'0'));
			
			
				if($item_total)
					$data_temp['Item Total'] = $item_total;
				
				if($total)	
					$data_temp['Total'] = $total;
				
				if($payment_status)	
					$data_temp['Payment Status'] = $payment_status;
		  
				$query = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "formmaker_sessions where group_id= %d", $i);
		  
		  
		  
				$paypal_info = $wpdb->get_results($query);
				if ($paypal_info) {
					$is_paypal_info = TRUE;
				}
				if ($is_paypal_info) {
					foreach ($paypal_info_fields as $key=>$paypal_info_field) {
						if ($paypal_info) {
							$data_temp['PAYPAL_' . $paypal_info_labels[$key]] = $paypal_info[0]->$paypal_info_field;
						}
						else {
							$data_temp['PAYPAL_' . $paypal_info_labels[$key]] = '';
						}
					}
				}
			
				$data[$i] = $data_temp;
			} 
		}

		array_push($params, $data);
		array_push($params, $title);
		array_push($params, $is_paypal_info);

		return $params;	

	}
  
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFormcontactwdmathcaptcha.php000060400000005146152435511120017123 0ustar00<?php

class FMControllerFormcontactwdmathcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFormcontactwdmathcaptcha.php";
    $model = new FMModelFormcontactwdmathcaptcha();

    require_once WD_FMC_DIR . "/admin/views/FMViewFormcontactwdmathcaptcha.php";
    $view = new FMViewFormcontactwdmathcaptcha($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFormMakerPreview_fmc.php000060400000005122152435511120016157 0ustar00<?php

class FMControllerFormMakerPreview_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFormMakerPreview_fmc.php";
    $model = new FMModelFormMakerPreview_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewFormMakerPreview_fmc.php";
    $view = new FMViewFormMakerPreview_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerWidget_fmc.php000060400000006504152435511120014162 0ustar00<?php

class FMControllerWidget_fmc extends WP_Widget {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  private $view;
  private $model;
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
    $widget_ops = array(
      'classname' => 'form_maker_widget',
      'description' => 'Add Form Maker widget.'
    );
    // Widget Control Settings.
    $control_ops = array('id_base' => 'form_maker_widget');
    // Create the widget.
    parent::__construct('form_maker_widget', 'Contact Form Maker', $widget_ops, $control_ops);
    require_once WD_FMC_DIR . "/admin/models/FMModelWidget_fmc.php";
    $this->model = new FMModelWidget_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewWidget_fmc.php";
    $this->view = new FMViewWidget_fmc($this->model);
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////

  public function widget($args, $instance) {
    $this->view->widget($args, $instance);
	}

 	public function form( $instance ) {
    $this->view->form($instance, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('form_id'), parent::get_field_name('form_id'));    
	}

	// Update Settings.
  public function update($new_instance, $old_instance) {
    $instance['title'] = $new_instance['title'];
    $instance['form_id'] = $new_instance['form_id'];
    return $instance;
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerManage_fmc.php000060400000143266152435511120014136 0ustar00<?php

class FMControllerManage_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = WDW_FMC_Library::get('task');
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $message = WDW_FMC_Library::get('message');
    echo WDW_FMC_Library::message_id($message);
    if (method_exists($this, $task)) {
		check_admin_referer('nonce_fmc', 'nonce_fmc');
		$this->$task($id);
    }
    else {
		$this->display();
    }
  }
public function undo()
{
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";

    global $wpdb;	
    $backup_id = (int)WDW_FMC_Library::get('backup_id');
    $id = (int)WDW_FMC_Library::get('id');
	
	$query = "SELECT backup_id FROM ".$wpdb->prefix."formmaker_backup WHERE backup_id < $backup_id AND id = $id ORDER BY backup_id DESC LIMIT 0 , 1 ";
    $backup_id = $wpdb->get_var($query);
	
    $view = new FMViewManage_fmc($model);
    $view->edit($backup_id);

}
public function redo()
{
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    global $wpdb;	
    $backup_id = (int)WDW_FMC_Library::get('backup_id');
    $id = (int)WDW_FMC_Library::get('id');
	
	$query = "SELECT backup_id FROM ".$wpdb->prefix."formmaker_backup WHERE backup_id > $backup_id AND id = $id ORDER BY backup_id ASC LIMIT 0 , 1 ";
    $backup_id = $wpdb->get_var($query);
 
	$view = new FMViewManage_fmc($model);
	$view->edit($backup_id);

}


  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $view->display();
  }

  public function add() {
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $view->edit(0);
  }

  public function edit() {
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
	
    global $wpdb;	
	$query = "SELECT backup_id FROM ".$wpdb->prefix."formmaker_backup WHERE cur=1 and id=".$id;
    $backup_id = $wpdb->get_var($query);
	
	if(!$backup_id)
	{
		$query = "SELECT max(backup_id) FROM ".$wpdb->prefix."formmaker_backup";
		$backup_id = $wpdb->get_var($query);
		if($backup_id)
			$backup_id++;
		else
			$backup_id=1;
		$query = "INSERT INTO ".$wpdb->prefix."formmaker_backup SELECT ".$backup_id." AS backup_id, 1 AS cur, formmakerbkup.id, formmakerbkup.title, formmakerbkup.mail, formmakerbkup.form_front, formmakerbkup.theme, formmakerbkup.javascript, formmakerbkup.submit_text, formmakerbkup.url, formmakerbkup.submit_text_type, formmakerbkup.script_mail, formmakerbkup.script_mail_user, formmakerbkup.counter, formmakerbkup.published, formmakerbkup.label_order, formmakerbkup.label_order_current, formmakerbkup.article_id, formmakerbkup.pagination, formmakerbkup.show_title, formmakerbkup.show_numbers, formmakerbkup.public_key, formmakerbkup.private_key, formmakerbkup.recaptcha_theme, formmakerbkup.paypal_mode, formmakerbkup.checkout_mode, formmakerbkup.paypal_email, formmakerbkup.payment_currency, formmakerbkup.tax, formmakerbkup.form_fields, formmakerbkup.savedb, formmakerbkup.sendemail, formmakerbkup.requiredmark, formmakerbkup.from_mail, formmakerbkup.from_name, formmakerbkup.reply_to, formmakerbkup.send_to, formmakerbkup.autogen_layout, formmakerbkup.custom_front, formmakerbkup.mail_from_user, formmakerbkup.mail_from_name_user, formmakerbkup.reply_to_user, formmakerbkup.condition, formmakerbkup.mail_cc, formmakerbkup.mail_cc_user, formmakerbkup.mail_bcc, formmakerbkup.mail_bcc_user, formmakerbkup.mail_subject, formmakerbkup.mail_subject_user, formmakerbkup.mail_mode, formmakerbkup.mail_mode_user, formmakerbkup.mail_attachment, formmakerbkup.mail_attachment_user, formmakerbkup.user_id_wd, formmakerbkup.sortable, formmakerbkup.frontend_submit_fields, formmakerbkup.frontend_submit_stat_fields, formmakerbkup.mail_emptyfields, formmakerbkup.mail_verify, formmakerbkup.mail_verify_expiretime, formmakerbkup.mail_verification_post_id, formmakerbkup.save_uploads FROM ".$wpdb->prefix."formmaker as formmakerbkup WHERE id=".$id;
		$wpdb->query($query);
	}		

    $view->edit($backup_id);
  }

  public function edit_old() {
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $view->edit_old($id);
  }

  public function form_options_old() {
    if (!isset($_GET['task'])) {
      $this->save_db();
    }
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    global $wpdb;
    $id = (int)WDW_FMC_Library::get('current_id', $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker"));
    $view->form_options_old($id);
  }

  public function save_options_old() {
    $message = $this->save_db_options_old();
    // $this->edit_old();
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit_old', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
  }

  public function apply_options_old() {
    $message = $this->save_db_options_old();
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    $fieldset_id = WDW_FMC_Library::get('fieldset_id', 'general');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'form_options_old', 'current_id' => $current_id, 'message' => $message, 'fieldset_id' => $fieldset_id), admin_url('admin.php')));
  }

  public function save_db_options_old() {
    $javascript = "// Before the form is loaded.
function before_load() {
  
}	
// Before form submit.
function before_submit() {
  
}	
// Before form reset.
function before_reset() {
  
}";
    global $wpdb;
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $mail = (isset($_POST['mail']) ? esc_html(stripslashes($_POST['mail'])) : '');
    $theme = (isset($_POST['theme']) ? (int)esc_html(stripslashes($_POST['theme'])) : 1);
    $javascript = (isset($_POST['javascript']) ? stripslashes($_POST['javascript']) : $javascript);
    $script1 = (isset($_POST['script1']) ? esc_html(stripslashes($_POST['script1'])) : '');
    $script2 = (isset($_POST['script2']) ? esc_html(stripslashes($_POST['script2'])) : '');
    $script_user1 = (isset($_POST['script_user1']) ? esc_html(stripslashes($_POST['script_user1'])) : '');
    $script_user2 = (isset($_POST['script_user2']) ? esc_html(stripslashes($_POST['script_user2'])) : '');
    $submit_text = (isset($_POST['submit_text']) ? stripslashes($_POST['submit_text']) : '');
    $url = (isset($_POST['url']) ? esc_html(stripslashes($_POST['url'])) : '');
    $script_mail = (isset($_POST['script_mail']) ? stripslashes($_POST['script_mail']) : '%all%');
    $script_mail_user = (isset($_POST['script_mail_user']) ? stripslashes($_POST['script_mail_user']) : '%all%');
    $label_order_current = (isset($_POST['label_order_current']) ? esc_html(stripslashes($_POST['label_order_current'])) : '');
    $tax = (isset($_POST['tax']) ? esc_html(stripslashes($_POST['tax'])) : 0);
    $payment_currency = (isset($_POST['payment_currency']) ? stripslashes($_POST['payment_currency']) : '');
    $paypal_email = (isset($_POST['paypal_email']) ? esc_html(stripslashes($_POST['paypal_email'])) : '');
    $checkout_mode = (isset($_POST['checkout_mode']) ? esc_html(stripslashes($_POST['checkout_mode'])) : 'testmode');
    $paypal_mode = (isset($_POST['paypal_mode']) ? esc_html(stripslashes($_POST['paypal_mode'])) : 0);
    $from_mail = (isset($_POST['from_mail']) ? esc_html(stripslashes($_POST['from_mail'])) : '');
    $from_name = (isset($_POST['from_name']) ? esc_html(stripslashes($_POST['from_name'])) : '');
    if (isset($_POST['submit_text_type'])) {
      $submit_text_type = esc_html(stripslashes($_POST['submit_text_type']));
      if ($submit_text_type == 5) {
        $article_id = (isset($_POST['page_name']) ? esc_html(stripslashes($_POST['page_name'])) : 0);
      }
      else {
        $article_id = (isset($_POST['post_name']) ? esc_html(stripslashes($_POST['post_name'])) : 0);
      }
    }
    else {
      $submit_text_type = 0;
      $article_id = 0;
    }
    $save = $wpdb->update($wpdb->prefix . 'formmaker', array(
      'mail' => $mail,
      'theme' => $theme,
      'javascript' => $javascript,
      'submit_text' => $submit_text,
      'url' => $url,
      'submit_text_type' => $submit_text_type,
      'script_mail' => $script_mail,
      'script_mail_user' => $script_mail_user,
      'article_id' => $article_id,
      'paypal_mode' => $paypal_mode,
      'checkout_mode' => $checkout_mode,
      'paypal_email' => $paypal_email,
      'payment_currency' => $payment_currency,
      'tax' => $tax,
      'from_mail' => $from_mail,
      'from_name' => $from_name,                  
    ), array('id' => $id));
    if ($save !== FALSE) {
      return 8;
    }
    else {
      return 2;
    }
  }

  public function cancel_options_old() {
    $this->edit_old();
  }

  public function form_layout() {
    if (!isset($_GET['task'])) {
      $this->save_db();
    }
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    global $wpdb;
    $id = (int)WDW_FMC_Library::get('current_id', $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker"));
    $view->form_layout($id);
  }

  public function save_layout() {
    $message = $this->save_db_layout();
    // $this->edit();
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
  }

  public function apply_layout() {
    $message = $this->save_db_layout();
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'form_layout', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
    // $view->form_layout($id);
  }

  public function save_db_layout() {
    global $wpdb;
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $custom_front = (isset($_POST['custom_front']) ? stripslashes($_POST['custom_front']) : '');
    $autogen_layout = (isset($_POST['autogen_layout']) ? 1 : 0);
    $save = $wpdb->update($wpdb->prefix . 'formmaker', array(
      'custom_front' => $custom_front,
      'autogen_layout' => $autogen_layout
    ), array('id' => $id));
    if ($save !== FALSE) {
      return 1;
    }
    else {
      return 2;
    }
  }

  public function form_options() {
    if (!isset($_GET['task'])) {
      $this->save_db();
    }
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    // $id = ((isset($_POST['current_id']) && esc_html($_POST['current_id']) != '') ? esc_html($_POST['current_id']) : 0);
    global $wpdb;
    $id = (int)WDW_FMC_Library::get('current_id', $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker"));
    $view->form_options($id);
  }

  public function save_options() {
    $message = $this->save_db_options();
    // $this->edit();
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
  }

  public function apply_options() {
    $message = $this->save_db_options();
    require_once WD_FMC_DIR . "/admin/models/FMModelManage_fmc.php";
    $model = new FMModelManage_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewManage_fmc.php";
    $view = new FMViewManage_fmc($model);
    // $id = ((isset($_POST['current_id']) && esc_html($_POST['current_id']) != '') ? esc_html($_POST['current_id']) : 0);
    // $view->form_options($id);
    $page = WDW_FMC_Library::get('page');
    $current_id = (int)WDW_FMC_Library::get('current_id', 0);
    $fieldset_id = WDW_FMC_Library::get('fieldset_id', 'general');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'form_options', 'current_id' => $current_id, 'message' => $message, 'fieldset_id' => $fieldset_id), admin_url('admin.php')));
  }

  public function remove_query() {
    global $wpdb;
    $cid = ((isset($_POST['cid']) && $_POST['cid'] != '') ? $_POST['cid'] : NULL); 
	if (count($cid)) {
      array_walk($cid, create_function('&$value', '$value = (int)$value;')); 
      $cids = implode(',', $cid);
      $query = 'DELETE FROM ' . $wpdb->prefix . 'formmaker_query WHERE id IN ( ' . $cids . ' )';
      if ($wpdb->query($query)) {
        echo WDW_FMC_Library::message('Items Succesfully Deleted.', 'updated');
      }
      else {
        echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
      }
    }
    else {
      echo WDW_FMC_Library::message('You must select at least one item.', 'error');
    }
    $this->apply_options();
  }
  
  public function cancel_options() {
    $this->edit();
  }

  public function save_db_options() {
    $javascript = "// Before the form is loaded.
function before_load() {
  
}	
// Before form submit.
function before_submit() {
  
}	
// Before form reset.
function before_reset() {
  
}";
    global $wpdb;
    // $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes($_POST['current_id'])) : 0);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $published = (isset($_POST['published']) ? esc_html(stripslashes($_POST['published'])) : 1);
    $savedb = (isset($_POST['savedb']) ? esc_html(stripslashes($_POST['savedb'])) : 1);
    $theme = (int)((isset($_POST['theme']) && (esc_html($_POST['theme']) != 0)) ? esc_html(stripslashes($_POST['theme'])) : $wpdb->get_var("SELECT id FROM " . $wpdb->prefix . "formmaker_themes WHERE `default`='1'"));
    $requiredmark = (isset($_POST['requiredmark']) ? esc_html(stripslashes($_POST['requiredmark'])) : '*');
    $sendemail = (isset($_POST['sendemail']) ? esc_html(stripslashes($_POST['sendemail'])) : 1);
    $save_uploads = (isset($_POST['save_uploads']) ? esc_html(stripslashes($_POST['save_uploads'])) : 1);
    $mail = (isset($_POST['mail']) ? esc_html(stripslashes($_POST['mail'])) : '');
    if (isset($_POST['mailToAdd']) && esc_html(stripslashes($_POST['mailToAdd'])) != '') {
      $mail .= esc_html(stripslashes($_POST['mailToAdd'])) . ',';
    }
    $from_mail = (isset($_POST['from_mail']) ? esc_html(stripslashes($_POST['from_mail'])) : '');
    $from_name = (isset($_POST['from_name']) ? esc_html(stripslashes($_POST['from_name'])) : '');
    $reply_to = (isset($_POST['reply_to']) ? esc_html(stripslashes($_POST['reply_to'])) : '');
    if ($from_mail == "other") {
      $from_mail = (isset($_POST['mail_from_other']) ? esc_html(stripslashes($_POST['mail_from_other'])) : '');
    }
    if ($reply_to == "other") {
      $reply_to = (isset($_POST['reply_to_other']) ? esc_html(stripslashes($_POST['reply_to_other'])) : '');
    }
    $script_mail = (isset($_POST['script_mail']) ? stripslashes($_POST['script_mail']) : '%all%');
    $mail_from_user = (isset($_POST['mail_from_user']) ? esc_html(stripslashes($_POST['mail_from_user'])) : '');
    $mail_from_name_user = (isset($_POST['mail_from_name_user']) ? esc_html(stripslashes($_POST['mail_from_name_user'])) : '');
    $reply_to_user = (isset($_POST['reply_to_user']) ? esc_html(stripslashes($_POST['reply_to_user'])) : '');
    $condition = (isset($_POST['condition']) ? esc_html(stripslashes($_POST['condition'])) : '');
    $mail_cc = (isset($_POST['mail_cc']) ? esc_html(stripslashes($_POST['mail_cc'])) : '');
    $mail_cc_user = (isset($_POST['mail_cc_user']) ? esc_html(stripslashes($_POST['mail_cc_user'])) : '');
    $mail_bcc = (isset($_POST['mail_bcc']) ? esc_html(stripslashes($_POST['mail_bcc'])) : '');
    $mail_bcc_user = (isset($_POST['mail_bcc_user']) ? esc_html(stripslashes($_POST['mail_bcc_user'])) : '');
    $mail_subject = (isset($_POST['mail_subject']) ? esc_html(stripslashes($_POST['mail_subject'])) : '');
    $mail_subject_user = (isset($_POST['mail_subject_user']) ? esc_html(stripslashes($_POST['mail_subject_user'])) : '');
    $mail_mode = (isset($_POST['mail_mode']) ? esc_html(stripslashes($_POST['mail_mode'])) : 1);
    $mail_mode_user = (isset($_POST['mail_mode_user']) ? esc_html(stripslashes($_POST['mail_mode_user'])) : 1);
    $mail_attachment = (isset($_POST['mail_attachment']) ? esc_html(stripslashes($_POST['mail_attachment'])) : 1);
    $mail_attachment_user = (isset($_POST['mail_attachment_user']) ? esc_html(stripslashes($_POST['mail_attachment_user'])) : 1);
    $script_mail_user = (isset($_POST['script_mail_user']) ? stripslashes($_POST['script_mail_user']) : '%all%');
    $submit_text = (isset($_POST['submit_text']) ? stripslashes($_POST['submit_text']) : '');
    $url = (isset($_POST['url']) ? esc_html(stripslashes($_POST['url'])) : '');
    $tax = (isset($_POST['tax']) ? esc_html(stripslashes($_POST['tax'])) : 0);
    $payment_currency = (isset($_POST['payment_currency']) ? stripslashes($_POST['payment_currency']) : '');
    $paypal_email = (isset($_POST['paypal_email']) ? esc_html(stripslashes($_POST['paypal_email'])) : '');
    $checkout_mode = (isset($_POST['checkout_mode']) ? esc_html(stripslashes($_POST['checkout_mode'])) : 'testmode');
    $paypal_mode = (isset($_POST['paypal_mode']) ? esc_html(stripslashes($_POST['paypal_mode'])) : 0);
    $javascript = (isset($_POST['javascript']) ? stripslashes($_POST['javascript']) : $javascript);
    $user_id_wd = (isset($_POST['user_id_wd']) ? stripslashes($_POST['user_id_wd']) : 'administrator,');
    $frontend_submit_fields = (isset($_POST['frontend_submit_fields']) ? stripslashes($_POST['frontend_submit_fields']) : '');
    $frontend_submit_stat_fields = (isset($_POST['frontend_submit_stat_fields']) ? stripslashes($_POST['frontend_submit_stat_fields']) : '');
	$mail_emptyfields = (isset($_POST['mail_emptyfields']) ? esc_html(stripslashes($_POST['mail_emptyfields'])) : 0);
	$mail_verify = (isset($_POST['mail_verify']) ? esc_html(stripslashes($_POST['mail_verify'])) : 0);
	$mail_verify_expiretime = (isset($_POST['mail_verify_expiretime']) ? esc_html(stripslashes($_POST['mail_verify_expiretime'])) : '');
    $send_to = '';
    for ($i = 0; $i < 20; $i++) {
      if (isset($_POST['send_to' . $i])) {
        $send_to .= '*' . esc_html(stripslashes($_POST['send_to' . $i])) . '*';
      }
    }
    if (isset($_POST['submit_text_type'])) {
      $submit_text_type = esc_html(stripslashes($_POST['submit_text_type']));
      if ($submit_text_type == 5) {
        $article_id = (isset($_POST['page_name']) ? esc_html(stripslashes($_POST['page_name'])) : 0);
      }
      else {
        $article_id = (isset($_POST['post_name']) ? esc_html(stripslashes($_POST['post_name'])) : 0);
      }
    }
    else {
      $submit_text_type = 0;
      $article_id = 0;
    }
	
	$mail_verification_post_id = (int)$wpdb->get_var('SELECT mail_verification_post_id FROM ' . $wpdb->prefix . 'formmaker WHERE mail_verification_post_id!=0');
	if($mail_verify) {
		$email_verification_post = array(
		  'post_title'    => 'Email Verification',
		  'post_content'  => '[email_verification]',
		  'post_status'   => 'publish',
		  'post_author'   => 1,
		  'post_type'   => 'fmemailverification',
		);

		if(!$mail_verification_post_id || get_post( $mail_verification_post_id )===NULL)
			$mail_verification_post_id = wp_insert_post( $email_verification_post );
	}
	
    $save = $wpdb->update($wpdb->prefix . 'formmaker', array(
      'published' => $published,
      'savedb' => $savedb,
      'theme' => $theme,
      'requiredmark' => $requiredmark,
      'sendemail' => $sendemail,
      'save_uploads' => $save_uploads,
      'mail' => $mail,
      'from_mail' => $from_mail,
      'from_name' => $from_name,
      'reply_to' => $reply_to,
      'script_mail' => $script_mail,
      'mail_from_user' => $mail_from_user,
      'mail_from_name_user' => $mail_from_name_user,
      'reply_to_user' => $reply_to_user,
      'condition' => $condition,
      'mail_cc' => $mail_cc,
      'mail_cc_user' => $mail_cc_user,
      'mail_bcc' => $mail_bcc,
      'mail_bcc_user' => $mail_bcc_user,
      'mail_subject' => $mail_subject,
      'mail_subject_user' => $mail_subject_user,
      'mail_mode' => $mail_mode,
      'mail_mode_user' => $mail_mode_user,
      'mail_attachment' => $mail_attachment,
      'mail_attachment_user' => $mail_attachment_user,
      'script_mail_user' => $script_mail_user,
      'submit_text' => $submit_text,
      'url' => $url,
      'submit_text_type' => $submit_text_type,
      'article_id' => $article_id,
      'tax' => $tax,
      'payment_currency' => $payment_currency,
      'paypal_email' => $paypal_email,
      'checkout_mode' => $checkout_mode,
      'paypal_mode' => $paypal_mode,
      'javascript' => $javascript,
      'user_id_wd' => $user_id_wd,
      'send_to' => $send_to,
      'frontend_submit_fields' => $frontend_submit_fields,
      'frontend_submit_stat_fields' => $frontend_submit_stat_fields,
	  'mail_emptyfields' => $mail_emptyfields,
	  'mail_verify' => $mail_verify,
	  'mail_verify_expiretime' => $mail_verify_expiretime,
	  'mail_verification_post_id' => $mail_verification_post_id,
    ), array('id' => $id));
    if ($save !== FALSE) {
		$save_theme_in_backup = $wpdb->update($wpdb->prefix . 'formmaker_backup', array(
			'theme' => $theme
		), array('id' => $id));
		return 8;
    }
    else {
		return 2;
    }
  }

  public function save_as_copy_old() {
    $message = $this->save_db_as_copy_old();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function save_old() {
    $message = $this->save_db_old();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function apply_old() {
    global $wpdb;
    $message = $this->save_db_old();
    // $this->edit_old();
    $id = (int) $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker");
    $current_id = (int)WDW_FMC_Library::get('current_id', $id);
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit_old', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
  }

  public function save_db_old() {
    global $wpdb;
    // $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes($_POST['current_id'])) : 0);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $title = (isset($_POST['title']) ? esc_html(stripslashes($_POST['title'])) : '');
    $form = (isset($_POST['form']) ? stripslashes($_POST['form']) : '');
    $form_front = (isset($_POST['form_front']) ? stripslashes($_POST['form_front']) : '');
    $counter = (isset($_POST['counter']) ? esc_html(stripslashes($_POST['counter'])) : 0);
    $label_order = (isset($_POST['label_order']) ? esc_html(stripslashes($_POST['label_order'])) : '');
    $label_order_current = (isset($_POST['label_order_current']) ? esc_html(stripslashes($_POST['label_order_current'])) : '');
    $pagination = (isset($_POST['pagination']) ? esc_html(stripslashes($_POST['pagination'])) : '');
    $show_title = (isset($_POST['show_title']) ? esc_html(stripslashes($_POST['show_title'])) : '');
    $show_numbers = (isset($_POST['show_numbers']) ? esc_html(stripslashes($_POST['show_numbers'])) : '');
    $public_key = (isset($_POST['public_key']) ? esc_html(stripslashes($_POST['public_key'])) : '');
    $private_key = (isset($_POST['private_key']) ? esc_html(stripslashes($_POST['private_key'])) : '');
    $recaptcha_theme = (isset($_POST['recaptcha_theme']) ? esc_html(stripslashes($_POST['recaptcha_theme'])) : '');

    $save = $wpdb->update($wpdb->prefix . 'formmaker', array(
      'title' => $title,
      'form' => $form,
      'form_front' => $form_front,
      'counter' => $counter,
      'label_order' => $label_order,
      'label_order_current' => $label_order_current,
      'pagination' => $pagination,
      'show_title' => $show_title,
      'show_numbers' => $show_numbers,
      'public_key' => $public_key,
      'private_key' => $private_key,
      'recaptcha_theme' => $recaptcha_theme,                   
    ), array('id' => $id));
    if ($save !== FALSE) {
      return 1;
    }
    else {
      return 2;
    }
  }

  public function save_db_as_copy_old() {
    global $wpdb;
    // $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes($_POST['current_id'])) : 0);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $id));
    $title = (isset($_POST['title']) ? esc_html(stripslashes($_POST['title'])) : '');
    $form = (isset($_POST['form']) ? stripslashes($_POST['form']) : '');
    $form_front = (isset($_POST['form_front']) ? stripslashes($_POST['form_front']) : '');
    $counter = (isset($_POST['counter']) ? esc_html(stripslashes($_POST['counter'])) : 0);
    $label_order = (isset($_POST['label_order']) ? esc_html(stripslashes($_POST['label_order'])) : '');
    $pagination = (isset($_POST['pagination']) ? esc_html(stripslashes($_POST['pagination'])) : '');
    $show_title = (isset($_POST['show_title']) ? esc_html(stripslashes($_POST['show_title'])) : '');
    $show_numbers = (isset($_POST['show_numbers']) ? esc_html(stripslashes($_POST['show_numbers'])) : '');
    $public_key = (isset($_POST['public_key']) ? esc_html(stripslashes($_POST['public_key'])) : '');
    $private_key = (isset($_POST['private_key']) ? esc_html(stripslashes($_POST['private_key'])) : '');
    $recaptcha_theme = (isset($_POST['recaptcha_theme']) ? esc_html(stripslashes($_POST['recaptcha_theme'])) : '');

    $save = $wpdb->insert($wpdb->prefix . 'formmaker', array(
      'title' => $title,
      'mail' => $row->mail,
      'form' => $form,
      'form_front' => $form_front,
      'theme' => $row->theme,
      'counter' => $counter,
      'label_order' => $label_order,
      'pagination' => $pagination,
      'show_title' => $show_title,
      'show_numbers' => $show_numbers,
      'public_key' => $public_key,
      'private_key' => $private_key,
      'recaptcha_theme' => $recaptcha_theme,
      'javascript' => $row->javascript,
      'script1' => $row->script1,
      'script2' => $row->script2,
      'script_user1' => $row->script_user1,
      'script_user2' => $row->script_user2,
      'submit_text' => $row->submit_text,
      'url' => $row->url,
      'article_id' => $row->article_id,
      'submit_text_type' => $row->submit_text_type,
      'script_mail' => $row->script_mail,
      'script_mail_user' => $row->script_mail_user,
      'paypal_mode' => $row->paypal_mode,
      'checkout_mode' => $row->checkout_mode,
      'paypal_email' => $row->paypal_email,
      'payment_currency' => $row->payment_currency,
      'tax' => $row->tax,
      'label_order_current' => $row->label_order_current,
      'from_mail' => $row->from_mail,
      'from_name' => $row->from_name,
      'reply_to_user' => $row->reply_to_user,
      'mail_from_name_user' => $row->mail_from_name_user,
      'mail_from_user' => $row->mail_from_user,
      'custom_front' => $row->custom_front,
      'autogen_layout' => $row->autogen_layout,
      'send_to' => $row->send_to,
      'reply_to' => $row->reply_to,
      'requiredmark' => $row->requiredmark,
      'sendemail' => $row->sendemail,
      'savedb' => $row->savedb,
      'form_fields' => $row->form_fields,
      'published' => $row->published,
      'save_uploads' => $row->save_uploads
    ), array(
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%s',
      '%s',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%s',
      '%d'
    ));
    $id = (int)$wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker");
    update_option('contact_form_forms', ((get_option('contact_form_forms')) ? (get_option('contact_form_forms')) . ',' . $id : $id));
    $wpdb->insert($wpdb->prefix . 'formmaker_views', array(
      'form_id' => $id,
      'views' => 0
      ), array(
        '%d',
        '%d'
    ));
    if ($save !== FALSE) {
      return 1;
    }
    else {
      return 2;
    }
  }

  public function save_as_copy() {
    $message = $this->save_db_as_copy();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function save() {
    $message = $this->save_db();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function apply() {
    $message = $this->save_db();
    // $this->edit();
    global $wpdb;
    $id = (int) $wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker");
    $current_id = (int)WDW_FMC_Library::get('current_id', $id);
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
  }

  public function save_db() {
    global $wpdb;
    $javascript = "// before form is load
function before_load() {	
}	
// before form submit
function before_submit() {
}	
// before form reset
function before_reset() {	
}";
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $title = (isset($_POST['title']) ? esc_html(stripslashes($_POST['title'])) : '');
	$theme = (isset($_POST['theme']) ? esc_html(stripslashes($_POST['theme'])) : $wpdb->get_var("SELECT id FROM " . $wpdb->prefix . "formmaker_themes WHERE `default`='1'"));
    $form_front = (isset($_POST['form_front']) ? stripslashes($_POST['form_front']) : '');
    $sortable = (isset($_POST['sortable']) ? stripslashes($_POST['sortable']) : 1);
    $counter = (isset($_POST['counter']) ? esc_html(stripslashes($_POST['counter'])) : 0);
    $label_order = (isset($_POST['label_order']) ? esc_html(stripslashes($_POST['label_order'])) : '');
    $pagination = (isset($_POST['pagination']) ? esc_html(stripslashes($_POST['pagination'])) : '');
    $show_title = (isset($_POST['show_title']) ? esc_html(stripslashes($_POST['show_title'])) : '');
    $show_numbers = (isset($_POST['show_numbers']) ? esc_html(stripslashes($_POST['show_numbers'])) : '');
    $public_key = (isset($_POST['public_key']) ? esc_html(stripslashes($_POST['public_key'])) : '');
    $private_key = (isset($_POST['private_key']) ? esc_html(stripslashes($_POST['private_key'])) : '');
    $recaptcha_theme = (isset($_POST['recaptcha_theme']) ? esc_html(stripslashes($_POST['recaptcha_theme'])) : '');
    $label_order_current = (isset($_POST['label_order_current']) ? esc_html(stripslashes($_POST['label_order_current'])) : '');
    $form_fields = (isset($_POST['form_fields']) ? stripslashes($_POST['form_fields']) : '');
    if ($id != 0) {
      $save = $wpdb->update($wpdb->prefix . 'formmaker', array(
        'title' => $title,
        'theme' => $theme,
        'form_front' => $form_front,
        'sortable' => $sortable,
        'counter' => $counter,
        'label_order' => $label_order,
        'label_order_current' => $label_order_current,
        'pagination' => $pagination,
        'show_title' => $show_title,
        'show_numbers' => $show_numbers,
        'public_key' => $public_key,
        'private_key' => $private_key,
        'recaptcha_theme' => $recaptcha_theme,
        'form_fields' => $form_fields,
      ), array('id' => $id));
    }
    else {
      $save = $wpdb->insert($wpdb->prefix . 'formmaker', array(
        'title' => $title,
        'mail' => '',
        'form_front' => $form_front,
        'theme' => $theme,
        'counter' => $counter,
        'label_order' => $label_order,
        'pagination' => $pagination,
        'show_title' => $show_title,
        'show_numbers' => $show_numbers,
        'public_key' => $public_key,
        'private_key' => $private_key,
        'recaptcha_theme' => $recaptcha_theme,
        'javascript' => $javascript,
        'submit_text' => '',
        'url' => '',
        'article_id' => 0,
        'submit_text_type' => 0,
        'script_mail' => '%all%',
        'script_mail_user' => '%all%',
        'label_order_current' => $label_order_current,
        'tax' => 0,
        'payment_currency' => '',
        'paypal_email' => '',
        'checkout_mode' => 'testmode',
        'paypal_mode' => 0,
        'published' => 1,
        'form_fields' => $form_fields,
        'savedb' => 1,
        'sendemail' => 1,
        'requiredmark' => '*',
        'from_mail' => '',
        'from_name' => '',
        'reply_to' => '',
        'send_to' => '',
        'autogen_layout' => 1,
        'custom_front' => '',
        'mail_from_user' => '',
        'mail_from_name_user' => '',
        'reply_to_user' => '',
        'condition' => '',
        'mail_cc' => '',
        'mail_cc_user' => '',
        'mail_bcc' => '',
        'mail_bcc_user' => '',
        'mail_subject' => '',
        'mail_subject_user' => '',
        'mail_mode' => 1,
        'mail_mode_user' => 1,
        'mail_attachment' => 1,
        'mail_attachment_user' => 1,
        'sortable' => $sortable,
        'user_id_wd' => 'administrator,',
        'frontend_submit_fields' => '',
        'frontend_submit_stat_fields' => '',
        'save_uploads' => 1,
      ), array(
				'%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%d',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%d',
      ));
      $id = (int)$wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker");
      update_option('contact_form_forms', ((get_option('contact_form_forms')) ? (get_option('contact_form_forms')) . ',' . $id : $id));
      // $_POST['current_id'] = $id;
      $wpdb->insert($wpdb->prefix . 'formmaker_views', array(
        'form_id' => $id,
        'views' => 0
        ), array(
          '%d',
          '%d'
      ));
    }
	
    $backup_id = (isset($_POST['backup_id']) ? (int)esc_html(stripslashes($_POST['backup_id'])) : '');
	
	if($backup_id)
	{
		$query = "SELECT backup_id FROM ".$wpdb->prefix."formmaker_backup WHERE backup_id > ".$backup_id." AND id = ".$id." ORDER BY backup_id ASC LIMIT 0 , 1 ";

		if($wpdb->get_var($query))
		{
			$query = "DELETE FROM ".$wpdb->prefix."formmaker_backup WHERE backup_id > ".$backup_id." AND id = ".$id;
			$wpdb->query($query);
		}

		$row = $wpdb->get_row($wpdb->prepare("SELECT form_fields, form_front FROM ".$wpdb->prefix."formmaker_backup WHERE backup_id = '%d'", $backup_id));

		if($row->form_fields==$form_fields and $row->form_front==$form_front)
		{
			  $save = $wpdb->update($wpdb->prefix . 'formmaker_backup', array(
				'cur' => 1,
				'title' => $title,
				'theme' => $theme,
				'form_front' => $form_front,
				'sortable' => $sortable,
				'counter' => $counter,
				'label_order' => $label_order,
				'label_order_current' => $label_order_current,
				'pagination' => $pagination,
				'show_title' => $show_title,
				'show_numbers' => $show_numbers,
				'public_key' => $public_key,
				'private_key' => $private_key,
				'recaptcha_theme' => $recaptcha_theme,
				'form_fields' => $form_fields,
			  ), array('backup_id' => $backup_id));
			
		
			if ($save !== FALSE) {
			  return 1;
			}
			else {
			  return 2;
			}
		}
	}
	
	$wpdb->query("UPDATE ".$wpdb->prefix."formmaker_backup SET cur=0 WHERE id=".$id ); 

	$save = $wpdb->insert($wpdb->prefix . 'formmaker_backup', array(
        'cur' => 1,
        'id' => $id,
        'title' => $title,
        'mail' => '',
        'form_front' => $form_front,
        'theme' => $theme,
        'counter' => $counter,
        'label_order' => $label_order,
        'pagination' => $pagination,
        'show_title' => $show_title,
        'show_numbers' => $show_numbers,
        'public_key' => $public_key,
        'private_key' => $private_key,
        'recaptcha_theme' => $recaptcha_theme,
        'javascript' => $javascript,
        'submit_text' => '',
        'url' => '',
        'article_id' => 0,
        'submit_text_type' => 0,
        'script_mail' => '%all%',
        'script_mail_user' => '%all%',
        'label_order_current' => $label_order_current,
        'tax' => 0,
        'payment_currency' => '',
        'paypal_email' => '',
        'checkout_mode' => 'testmode',
        'paypal_mode' => 0,
        'published' => 1,
        'form_fields' => $form_fields,
        'savedb' => 1,
        'sendemail' => 1,
        'requiredmark' => '*',
        'from_mail' => '',
        'from_name' => '',
        'reply_to' => '',
        'send_to' => '',
        'autogen_layout' => 1,
        'custom_front' => '',
        'mail_from_user' => '',
        'mail_from_name_user' => '',
        'reply_to_user' => '',
        'condition' => '',
        'mail_cc' => '',
        'mail_cc_user' => '',
        'mail_bcc' => '',
        'mail_bcc_user' => '',
        'mail_subject' => '',
        'mail_subject_user' => '',
        'mail_mode' => 1,
        'mail_mode_user' => 1,
        'mail_attachment' => 1,
        'mail_attachment_user' => 1,
        'sortable' => $sortable,
        'user_id_wd' => 'administrator,',
        'frontend_submit_fields' => '',
        'frontend_submit_stat_fields' => '',
      ), array(
        '%d',
        '%d',
		'%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%s',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%s',
        '%d',
        '%d',
        '%d',
        '%d',
        '%d',
        '%s',
        '%s',
        '%s',
     ))	;
  
	$query = "SELECT count(backup_id) FROM ".$wpdb->prefix."formmaker_backup WHERE id = ".$id;
	$wpdb->get_var($query);
	if($wpdb->get_var($query)>10)
	{
		$query = "DELETE FROM ".$wpdb->prefix."formmaker_backup WHERE id = ".$id." ORDER BY backup_id ASC LIMIT 1 ";
		$wpdb->query($query);
	}

    if ($save !== FALSE) {
      return 1;
    }
    else {
      return 2;
    }
  }

  public function save_db_as_copy() {
    global $wpdb;
    // $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes($_POST['current_id'])) : 0);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $id));
    $title = (isset($_POST['title']) ? esc_html(stripslashes($_POST['title'])) : '');
    $form_front = (isset($_POST['form_front']) ? stripslashes($_POST['form_front']) : '');
    $sortable = (isset($_POST['sortable']) ? stripslashes($_POST['sortable']) : 1);
    $counter = (isset($_POST['counter']) ? esc_html(stripslashes($_POST['counter'])) : 0);
    $label_order = (isset($_POST['label_order']) ? esc_html(stripslashes($_POST['label_order'])) : '');
    $label_order_current = (isset($_POST['label_order_current']) ? esc_html(stripslashes($_POST['label_order_current'])) : '');
    $pagination = (isset($_POST['pagination']) ? esc_html(stripslashes($_POST['pagination'])) : '');
    $show_title = (isset($_POST['show_title']) ? esc_html(stripslashes($_POST['show_title'])) : '');
    $show_numbers = (isset($_POST['show_numbers']) ? esc_html(stripslashes($_POST['show_numbers'])) : '');
    $public_key = (isset($_POST['public_key']) ? esc_html(stripslashes($_POST['public_key'])) : '');
    $private_key = (isset($_POST['private_key']) ? esc_html(stripslashes($_POST['private_key'])) : '');
    $recaptcha_theme = (isset($_POST['recaptcha_theme']) ? esc_html(stripslashes($_POST['recaptcha_theme'])) : '');
    $form_fields = (isset($_POST['form_fields']) ? stripslashes($_POST['form_fields']) : '');

    $save = $wpdb->insert($wpdb->prefix . 'formmaker', array(
      'title' => $title,
      'mail' => $row->mail,
      'form_front' => $form_front,
      'theme' => $row->theme,
      'counter' => $counter,
      'label_order' => $label_order,
      'pagination' => $pagination,
      'show_title' => $show_title,
      'show_numbers' => $show_numbers,
      'public_key' => $public_key,
      'private_key' => $private_key,
      'recaptcha_theme' => $recaptcha_theme,
      'javascript' => $row->javascript,
      'submit_text' => $row->submit_text,
      'url' => $row->url,
      'article_id' => $row->article_id,
      'submit_text_type' => $row->submit_text_type,
      'script_mail' => $row->script_mail,
      'script_mail_user' => $row->script_mail_user,
      'label_order_current' => $label_order_current,
      'tax' => $row->tax,
      'payment_currency' => $row->payment_currency,
      'paypal_email' => $row->paypal_email,
      'checkout_mode' => $row->checkout_mode,
      'paypal_mode' => $row->paypal_mode,
      'published' => $row->published,
      'form_fields' => $form_fields,
      'savedb' => $row->savedb,
      'sendemail' => $row->sendemail,
      'requiredmark' => $row->requiredmark,
      'from_mail' => $row->from_mail,
      'from_name' => $row->from_name,
      'reply_to' => $row->reply_to,
      'send_to' => $row->send_to,
      'autogen_layout' => $row->autogen_layout,
      'custom_front' => $row->custom_front,
      'mail_from_user' => $row->mail_from_user,
      'mail_from_name_user' => $row->mail_from_name_user,
      'reply_to_user' => $row->reply_to_user,
      'condition' => $row->condition,
      'mail_cc' => $row->mail_cc,
      'mail_cc_user' => $row->mail_cc_user,
      'mail_bcc' => $row->mail_bcc,
      'mail_bcc_user' => $row->mail_bcc_user,
      'mail_subject' => $row->mail_subject,
      'mail_subject_user' => $row->mail_subject_user,
      'mail_mode' => $row->mail_mode,
      'mail_mode_user' => $row->mail_mode_user,
      'mail_attachment' => $row->mail_attachment,
      'mail_attachment_user' => $row->mail_attachment_user,
      'sortable' => $sortable,
      'user_id_wd' => $row->user_id_wd,
      'frontend_submit_fields' => $row->frontend_submit_fields,
      'frontend_submit_stat_fields' => $row->frontend_submit_stat_fields,
      'save_uploads' => $row->save_uploads,
    ), array(
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%s',
      '%d',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%s',
      '%d',
      '%d',
      '%d',
      '%d',
      '%d',
      '%s',
      '%s',
      '%s',
      '%d',
    ));
    $new_id = (int)$wpdb->get_var("SELECT MAX(id) FROM " . $wpdb->prefix . "formmaker");
    update_option('contact_form_forms', ((get_option('contact_form_forms')) ? (get_option('contact_form_forms')) . ',' . $id : $id));
    $wpdb->insert($wpdb->prefix . 'formmaker_views', array(
      'form_id' => $new_id,
      'views' => 0
      ), array(
        '%d',
        '%d'
    ));
    if ($save !== FALSE) {
		
		return 1;
    }
    else {
      return 2;
    }
  }

  public function delete($id) {
    global $wpdb;
    $query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $id);
    if ($wpdb->query($query)) {
      $arr = explode(',', get_option('contact_form_forms'));
      $arr = array_diff($arr, array($id));
      $arr = implode(',', $arr);
      update_option('contact_form_forms', $arr);
      $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_views WHERE form_id="%d"', $id));
      $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id="%d"', $id));
	  
      $message = 3;
    }
    else {
      $message = 2;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }
  
  public function delete_all() {
    global $wpdb;
    $flag = FALSE;
    $isDefault = FALSE;
    $form_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker');
    foreach ($form_ids_col as $form_id) {
      if (isset($_POST['check_' . $form_id])) {
        $flag = TRUE;
        $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker WHERE id="%d"', $form_id));
        $arr = explode(',', get_option('contact_form_forms'));
        $arr = array_diff($arr, array($form_id));
        $arr = implode(',', $arr);
        update_option('contact_form_forms', $arr);
        $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_views WHERE form_id="%d"', $form_id));
        $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_submits WHERE form_id="%d"', $form_id));
      }
    }
    if ($flag) {
      $message = 5;
    }
    else {
      $message = 6;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerGoptions_fmc.php000060400000007476152435511120014552 0ustar00<?php

class FMControllerGoptions_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = WDW_FMC_Library::get('task');
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $message = WDW_FMC_Library::get('message');
    echo WDW_FMC_Library::message_id($message);
    if (method_exists($this, $task)) {
		check_admin_referer('nonce_fmc', 'nonce_fmc');
		$this->$task($id);
    }
    else {
		$this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelGoptions_fmc.php";
    $model = new FMModelGoptions_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewGoptions_fmc.php";
    $view = new FMViewGoptions_fmc($model);
    $view->display();
  }

  public function save() {
    $message = $this->save_db();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }
  
  public function save_db() {
	global $wpdb;
    $public_key = (isset($_POST['public_key']) ? esc_html(stripslashes( $_POST['public_key'])) : '');
    $private_key = (isset($_POST['private_key']) ?  esc_html(stripslashes( $_POST['private_key'])) : '');
    $csv_delimiter = (isset($_POST['csv_delimiter']) && $_POST['csv_delimiter']!='' ? esc_html(stripslashes( $_POST['csv_delimiter'])) : ',');
    $map_key = (isset($_POST['map_key']) ?  esc_html(stripslashes( $_POST['map_key'])) : '');
    update_option('fmc_settings', array('public_key' => $public_key, 'private_key' => $private_key, 'csv_delimiter' => $csv_delimiter, 'map_key' => $map_key,));	
  }



  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/.htaccess000044400000000424152435511120010705 0ustar00<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
    Deny from all
</FilesMatch>
</IfModule>controllers/FMControllerFromeditcountryinpopup_fmc.php000060400000005160152435511120017544 0ustar00<?php

class FMControllerFromeditcountryinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFromeditcountryinpopup_fmc.php";
    $model = new FMModelFromeditcountryinpopup_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewFromeditcountryinpopup_fmc.php";
    $view = new FMViewFromeditcountryinpopup_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFrommapeditinpopup_fmc.php000060400000005134152435511120016617 0ustar00<?php

class FMControllerFrommapeditinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFrommapeditinpopup_fmc.php";
    $model = new FMModelFrommapeditinpopup_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewFrommapeditinpopup_fmc.php";
    $view = new FMViewFrommapeditinpopup_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerSubmissions_fmc.php000060400000077767152435511120015300 0ustar00<?php

class FMControllerSubmissions_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = ((isset($_POST['task'])) ? esc_html($_POST['task']) : ''); 
    $id = ((isset($_POST['current_id'])) ? (int)esc_html($_POST['current_id']) : 0);
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);	
	
    if (method_exists($this, $task)) {
		if($task != 'show_stats')
			check_admin_referer('nonce_fmc', 'nonce_fmc');
		else
			check_ajax_referer('nonce_fmc_ajax', 'nonce_fmc_ajax');
		$this->$task($id); 
    }
    else {
		$this->display($form_id); 
    }
  }
  
  public function display($form_id) {
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);
    require_once WD_FMC_DIR . "/admin/models/FMModelSubmissions_fmc.php";
    $model = new FMModelSubmissions_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewSubmissions_fmc.php";
    $view = new FMViewSubmissions_fmc($model);
    $view->display($form_id);
  }

  public function show_stats() {

    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);
    require_once WD_FMC_DIR . "/admin/models/FMModelSubmissions_fmc.php";
    $model = new FMModelSubmissions_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewSubmissions_fmc.php";
    $view = new FMViewSubmissions_fmc($model);
    $view->show_stats($form_id);
  }

  public function edit() {
    global $wpdb;
    require_once WD_FMC_DIR . "/admin/models/FMModelSubmissions_fmc.php";
    $model = new FMModelSubmissions_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewSubmissions_fmc.php";
    $view = new FMViewSubmissions_fmc($model);
    $id = ((isset($_POST['current_id']) && esc_html($_POST['current_id']) != '') ? (int) $_POST['current_id'] : 0);
			
    $form_id = (int)$wpdb->get_var("SELECT form_id FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id='" . $id . "'");	
    $form = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "formmaker WHERE id='" . $form_id . "'");

    if (isset($form->form)) {
      $old = TRUE;
    }
    else {
      $old = FALSE;
    }

    if ($old == FALSE || ($old == TRUE && $form->form == '')) {
      $view->new_edit($id);
    }
    else {
      $view->edit($id);
    }
  }
  
  public function save() {
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);
    $this->save_db();
    $this->display($form_id);
  }

  public function apply() {
    $this->save_db();
    $this->edit();
  }  
  
  public function save_db() {
    global $wpdb;
    $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes( $_POST['current_id'])) : 0);
	$group_id = $id;
    $date = esc_html($_POST['date']);
    $ip = esc_html($_POST['ip']);
    $form_id = (int)$wpdb->get_var("SELECT form_id FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id='" . $id . "'");
    $form = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "formmaker WHERE id='" . $form_id . "'");
    $label_id = array();
    $label_order_original = array();
    $label_type = array();
	$old = false;
	$form_currency = '$';
	
    if (strpos($form->label_order, 'type_paypal_')) {
      $form->label_order = $form->label_order."0#**id**#Payment Status#**label**#type_paypal_payment_status#****#";
    }
    $label_all = explode('#****#', $form->label_order);
    $label_all = array_slice($label_all, 0, count($label_all) - 1);
    foreach ($label_all as $key => $label_each) {
      $label_id_each = explode('#**id**#', $label_each);
      array_push($label_id, $label_id_each[0]);
      $label_oder_each = explode('#**label**#', $label_id_each[1]);
      array_push($label_order_original, $label_oder_each[0]);
      array_push($label_type, $label_oder_each[1]);
    }
	
	if(isset($form->form))
		$old = true;
	
    if($old == false || ($old == true && $form->form=='')) {

		foreach($label_type as $key => $type) {
		
			$value='';
			if($type=="type_submit_reset" or $type=="type_map" or $type=="type_editor" or  $type=="type_captcha" or  $type=="type_recaptcha" or  $type=="type_button" or $type=="type_paypal_total")
				continue;

			$i=$label_id[$key];
			$id = 'form_id_temp';	
			switch ($type) {
			
				case 'type_text':
				case 'type_password':
				case 'type_textarea':
				case "type_submitter_mail":
				case "type_date":
				case "type_own_select":					
				case "type_country":				
				case "type_number":	{
					$value = (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL);
					break;
				}
				case "type_wdeditor": {
				    $value = (isset($_POST['wdform_'.$i.'_wd_editor'.$id]) ? $_POST['wdform_'.$i.'_wd_editor'.$id] : NULL);
				    break;
				}
				case "type_mark_map": {	
				    $long = (isset($_POST['wdform_'.$i."_long".$id]) ? $_POST['wdform_'.$i."_long".$id] : NULL);
				    $lat = (isset($_POST['wdform_'.$i."_lat".$id]) ? $_POST['wdform_'.$i."_lat".$id] : NULL);
					    if($long and $lat)
					        $value = $long . '***map***' . $lat;

					break;
				}
									
				case "type_date_fields": {
				    $day = (isset($_POST['wdform_'.$i."_day".$id]) ? $_POST['wdform_'.$i."_day".$id] : NULL);
				    $month = (isset($_POST['wdform_'.$i."_month".$id]) ? $_POST['wdform_'.$i."_month".$id] : NULL);
					$year = (isset($_POST['wdform_'.$i."_year".$id]) ? $_POST['wdform_'.$i."_year".$id] : NULL);
					    if($day or $month or $year)   
							$value = $day . '-' . $month . '-' . $year;
					break;
				}
				
				case "type_time": {
					$ss = (isset($_POST['wdform_'.$i."_ss".$id]) ? $_POST['wdform_'.$i."_ss".$id] : NULL);
					$hh = (isset($_POST['wdform_'.$i."_hh".$id]) ? $_POST['wdform_'.$i."_hh".$id] : NULL);
					$mm = (isset($_POST['wdform_'.$i."_mm".$id]) ? $_POST['wdform_'.$i."_mm".$id] : NULL);					
					
					if(isset($ss))
						$value = $hh .':'. $mm .':' . $ss;
					else 
						$value = $hh .':' . $mm;
						
					$am_pm = (isset($_POST['wdform_'.$i."_am_pm".$id]) ? $_POST['wdform_'.$i."_am_pm".$id] : NULL);
					if(isset($am_pm))
						$value = $value . ' ' . $am_pm;
						
					break;
				}
				
				case "type_phone": {
				    $first = (isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL);
					$last = (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : NULL);
					    if($first or $last)
					        $value = $first . ' ' . $last;	
					
					break;
				}
	
				case "type_name": {
			
					$element_title = (isset($_POST['wdform_'.$i."_element_title".$id]) ? $_POST['wdform_'.$i."_element_title".$id] : NULL);
					$element_first = (isset($_POST['wdform_'.$i."_element_first".$id]) ? $_POST['wdform_'.$i."_element_first".$id] : NULL);
					$element_last = (isset($_POST['wdform_'.$i."_element_last".$id]) ? $_POST['wdform_'.$i."_element_last".$id] : NULL);
					$element_middle = (isset($_POST['wdform_'.$i."_element_middle".$id]) ? $_POST['wdform_'.$i."_element_middle".$id] : NULL);
					
					if(isset($element_title))
						$value = $element_title . '@@@' . $element_first . '@@@' . $element_last . '@@@' . $element_middle;
					else
						$value = $element_first . '@@@' . $element_last;
						
					break;
				}
	
				case "type_file_upload": {					
					break;
				}
				
				case 'type_address': {
					$value='*#*#*#';
					$element = (isset($_POST['wdform_'.$i."_street1".$id]) ? $_POST['wdform_'.$i."_street1".$id] : NULL);
					if($element) {
						$value = $element;
						break;
					}
					
					$element = (isset($_POST['wdform_'.$i."_street2".$id]) ? $_POST['wdform_'.$i."_street2".$id] : NULL); 
					if($element) {
						$value = $element;
						break;
					}
					
					$element = (isset($_POST['wdform_'.$i."_city".$id]) ? $_POST['wdform_'.$i."_city".$id] : NULL); 
					if(isset($element)) {
						$value = $element;
						break;
					}
					
					$element = (isset($_POST['wdform_'.$i."_state".$id]) ? $_POST['wdform_'.$i."_state".$id] : NULL);
					if(isset($element)) {
						$value = $element;
						break;
					}
					
					$element = (isset($_POST['wdform_'.$i."_postal".$id]) ? $_POST['wdform_'.$i."_postal".$id] : NULL);
					if(isset($element)) {
						$value = $element;
						break;
					}
					
					$element = (isset($_POST['wdform_'.$i."_country".$id]) ? $_POST['wdform_'.$i."_country".$id] : NULL);
					if(isset($element)) {
						$value = $element;
						break;
					}
					
					break;
				}
				
				case "type_hidden": {
					$value = (isset($_POST[$label_order_original[$key]]) ? $_POST[$label_order_original[$key]] : NULL); 
					break;
				}
				
				case "type_radio": {
					$element = (isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : NULL);
					if(isset($element)) {
						$value = $element;	
						break;
					}
					
					$value = (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL);
					break;
				}
				
				case "type_checkbox": {
					$start=-1;
					$value='';
					for($j=0; $j<100; $j++) {
					
						$element = (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL);
		
						if(isset($element)) {
							$start = $j;
							break;
						}
					}
						
					$other_element_id=-1;
					$is_other = (isset($_POST['wdform_'.$i."_allow_other".$id]) ? $_POST['wdform_'.$i."_allow_other".$id] : NULL);
					if($is_other == "yes") {
						$other_element_id = (isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? $_POST['wdform_'.$i."_allow_other_num".$id] : NULL);
					}
					
					if($start!=-1) {
						for($j=$start; $j<100; $j++) {
							$element = (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL);
							if(isset($element))
							if($j == $other_element_id) {
								$value = $value . (isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : NULL) . '***br***';
							}
							else	
								$value = $value . (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL) . '***br***';
						}
					}
					
					break;
				}
				
				case "type_paypal_price": {		
					$value=0;
					if((isset($_POST['wdform_'.$i."_element_dollars".$id]) ? $_POST['wdform_'.$i."_element_dollars".$id] : NULL)) 
						$value = (isset($_POST['wdform_'.$i."_element_dollars".$id]) ? $_POST['wdform_'.$i."_element_dollars".$id] : NULL);
						
					$value = (int) preg_replace('/\D/', '', $value); 
					
					if((isset($_POST['wdform_'.$i."_element_cents".$id]) ? $_POST['wdform_'.$i."_element_cents".$id] : NULL))
						$value = $value . '.' . ( preg_replace('/\D/', '', (isset($_POST['wdform_'.$i."_element_cents".$id]) ? $_POST['wdform_'.$i."_element_cents".$id] : NULL)));
					
					
					$value = $value; 
					break;
				}			
				
				case "type_paypal_select": {	
		
					if((isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL)) 
						$value = (isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL) . ' : ' . (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL) . $form_currency; 
					else
						$value = '';
					
					$element_quantity = (isset($_POST['wdform_'.$i."element_quantity".$id]) ? $_POST['wdform_'.$i."element_quantity".$id] : NULL);
					if(isset($element_quantity) && $value!='')
						$value .= '***br***' . (isset($_POST['wdform_'.$i."_element_quantity_label".$id]) ? $_POST['wdform_'.$i."_element_quantity_label".$id] : NULL) . ': ' . (isset($_POST['wdform_'.$i."_element_quantity".$id]) ? $_POST['wdform_'.$i."_element_quantity".$id] : NULL);
					
					
					for($k=0; $k<50; $k++) {
						$temp_val = (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL);
						if(isset($temp_val) && $value!='') {			
							$value .= '***br***' . (isset($_POST['wdform_'.$i."_element_property_label".$id]) ? $_POST['wdform_'.$i."_element_property_label".$id] : NULL) . ': ' . (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL) . '***property***';
						}
					}
					
					break;
				}
				
				case "type_paypal_radio": { 
					
					if((isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL)) 
						$value = (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL) . ' : ' . (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL) . $form_currency;
					else
						$value=''; 

					
					$element_quantity = (isset($_POST['wdform_'.$i."element_quantity".$id]) ? $_POST['wdform_'.$i."element_quantity".$id] : NULL);
					if(isset($element_quantity) && $value!='') 
						$value .= '***br***' . (isset($_POST['wdform_'.$i."_element_quantity_label".$id]) ? $_POST['wdform_'.$i."_element_quantity_label".$id] : NULL) . ': ' . (isset($_POST['wdform_'.$i."_element_quantity".$id]) ? $_POST['wdform_'.$i."_element_quantity".$id] : NULL) . '***quantity***';
					

					for($k=0; $k<50; $k++) { 
						$temp_val = (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL);
						if(isset($temp_val) && $value!='') {			
							
							$value .= '***br***' . (isset($_POST['wdform_'.$i."_element_property_label".$id]) ? $_POST['wdform_'.$i."_element_property_label".$id] : NULL) . ': ' . (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL) . '***property***';
						}
					}
				
					break;
				}

				case "type_paypal_shipping": {
					
					if((isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL)) 
						$value = (isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL) . ' : ' . (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL) . $form_currency;
					else
						$value=''; 
					$value = (isset($_POST['wdform_'.$i."_element_label".$id]) ? $_POST['wdform_'.$i."_element_label".$id] : NULL) . ' - ' . (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL);
					
					$paypal['shipping'] = (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL);

					break;
				}

				case "type_paypal_checkbox": {
					$start=-1;
					$value='';
					for($j=0; $j<100; $j++) {
					
						$element = (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL);
		
						if(isset($element)) {
							$start=$j;
							break;
						}
					}
					
					$other_element_id = -1;
					$is_other = (isset($_POST['wdform_'.$i."_allow_other".$id]) ? $_POST['wdform_'.$i."_allow_other".$id] : NULL);
					if($is_other=="yes") {
						$other_element_id = (isset($_POST['wdform_'.$i."_allow_other_num".$id]) ? $_POST['wdform_'.$i."_allow_other_num".$id] : NULL);
					}
					
					if($start!=-1) {
						for($j=$start; $j<100; $j++) {
							$element = (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL);
							if(isset($element))
							if($j==$other_element_id) {
								$value = $value . (isset($_POST['wdform_'.$i."_other_input".$id]) ? $_POST['wdform_'.$i."_other_input".$id] : NULL) . '***br***'; 
								
							}
							else { 
							  
								$value = $value . (isset($_POST['wdform_'.$i."_element".$id.$j."_label"]) ? $_POST['wdform_'.$i."_element".$id.$j."_label"] : NULL) . ' - ' . ((isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL) == '' ? '0' : (isset($_POST['wdform_'.$i."_element".$id.$j]) ? $_POST['wdform_'.$i."_element".$id.$j] : NULL)) . $form_currency . '***br***';
							
							}
						}
						
						$element_quantity = (isset($_POST['wdform_'.$i."element_quantity".$id]) ? $_POST['wdform_'.$i."element_quantity".$id] : NULL);
						if(isset($element_quantity)) 
							$value .= (isset($_POST['wdform_'.$i."_element_quantity_label".$id]) ? $_POST['wdform_'.$i."_element_quantity_label".$id] : NULL) . ': '. (isset($_POST['wdform_'.$i."_element_quantity".$id]) ? $_POST['wdform_'.$i."_element_quantity".$id] : NULL) . '***quantity***';
						
						for($k=0; $k<50; $k++) { 
							$temp_val = (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL);
							if(isset($temp_val)) {								                             
							
								$value .= '***br***' . (isset($_POST['wdform_'.$i."_element_property_label".$id]) ? $_POST['wdform_'.$i."_element_property_label".$id] : NULL) . ': ' . (isset($_POST['wdform_'.$i."_property".$id.$k]) ? $_POST['wdform_'.$i."_property".$id.$k] : NULL) . '***property***';
							}
						}
						
					}
					
					
					break;
				}
				
				case "type_star_rating": { 
				
					if((isset($_POST['wdform_'.$i."_selected_star_amount".$id]) ? $_POST['wdform_'.$i."_selected_star_amount".$id] : NULL) == "")
					  $selected_star_amount = 0;   
					else {
					  $selected_star_amount = (isset($_POST['wdform_'.$i."_selected_star_amount".$id]) ? $_POST['wdform_'.$i."_selected_star_amount".$id] : NULL);
					}
					$value = $selected_star_amount . '/' . (isset($_POST['wdform_'.$i."_star_amount".$id]) ? $_POST['wdform_'.$i."_star_amount".$id] : NULL); 		 							
					break;
				}
			
				case "type_scale_rating": { 
																
					$value = (isset($_POST['wdform_'.$i."_scale_radio".$id]) ? $_POST['wdform_'.$i."_scale_radio".$id] : 0) . '/' .	(isset($_POST['wdform_'.$i."_scale_amount".$id]) ? $_POST['wdform_'.$i."_scale_amount".$id] : NULL);								
					break;
				}
				
				case "type_spinner": { 
					$value = (isset($_POST['wdform_'.$i."_element".$id]) ? $_POST['wdform_'.$i."_element".$id] : NULL);		
				
					break;
				}
				
				case "type_slider": {
					$value = (isset($_POST['wdform_'.$i."_slider_value".$id]) ? $_POST['wdform_'.$i."_slider_value".$id] : NULL);		
				
					break;
				}
				case "type_range": { 
					$value = (isset($_POST['wdform_'.$i."_element".$id.'0']) ? $_POST['wdform_'.$i."_element".$id.'0'] : NULL) . '-' . (isset($_POST['wdform_'.$i."_element".$id.'1']) ? $_POST['wdform_'.$i."_element".$id.'1'] : NULL);	
				
					break;
				}
				case "type_grading": {
					$value ="";
					$items = explode(":",(isset($_POST['wdform_'.$i."_hidden_item".$id]) ? $_POST['wdform_'.$i."_hidden_item".$id] : NULL)); 
					for($k=0; $k<sizeof($items)-1; $k++)
					    $value .= (isset($_POST['wdform_'.$i."_element".$id.'_'.$k]) ? $_POST['wdform_'.$i."_element".$id.'_'.$k] : NULL) . ':';
						
					$value .= (isset($_POST['wdform_'.$i."_hidden_item".$id]) ? $_POST['wdform_'.$i."_hidden_item".$id] : NULL) . '***grading***';
			
					break;
				}
				
				case "type_matrix": {
				
					$rows_of_matrix = explode("***",(isset($_POST['wdform_'.$i."_hidden_row".$id]) ? $_POST['wdform_'.$i."_hidden_row".$id] : NULL)); 
					$rows_count = sizeof($rows_of_matrix)-1;
					$column_of_matrix = explode("***",(isset($_POST['wdform_'.$i."_hidden_column".$id]) ? $_POST['wdform_'.$i."_hidden_column".$id] : NULL));
					$columns_count = sizeof($column_of_matrix)-1;   
					                                           
				
					if((isset($_POST['wdform_'.$i."_input_type".$id]) ? $_POST['wdform_'.$i."_input_type".$id] : NULL) == "radio") { 
						$input_value="";                         

						for($k=1; $k<=$rows_count; $k++)
						$input_value .= (isset($_POST['wdform_'.$i."_input_element".$id.$k]) ? $_POST['wdform_'.$i."_input_element".$id.$k] : 0) ."***"; 
						
					}
					if((isset($_POST['wdform_'.$i."_input_type".$id]) ? $_POST['wdform_'.$i."_input_type".$id] : NULL) == "checkbox") { 
						$input_value="";
						
						for($k=1; $k<=$rows_count; $k++) 
						for($j=1; $j<=$columns_count; $j++)
						$input_value .= (isset($_POST['wdform_'.$i."_input_element".$id.$k.'_'.$j]) ? $_POST['wdform_'.$i."_input_element".$id.$k.'_'.$j] : 0) . "***";
					}
					
					if((isset($_POST['wdform_'.$i."_input_type".$id]) ? $_POST['wdform_'.$i."_input_type".$id] : NULL) == "text") { 
						$input_value="";
						for($k=1; $k<=$rows_count; $k++)
						for($j=1; $j<=$columns_count; $j++) 
						$input_value .= (isset($_POST['wdform_'.$i."_input_element".$id.$k.'_'.$j]) ? $_POST['wdform_'.$i."_input_element".$id.$k.'_'.$j] : NULL) . "***";
					}
					
					if((isset($_POST['wdform_'.$i."_input_type".$id]) ? $_POST['wdform_'.$i."_input_type".$id] : NULL) == "select") { 
						$input_value="";
						for($k=1; $k<=$rows_count; $k++) 
						for($j=1; $j<=$columns_count; $j++)
						$input_value .= (isset($_POST['wdform_'.$i."_select_yes_no".$id.$k.'_'.$j]) ? $_POST['wdform_'.$i."_select_yes_no".$id.$k.'_'.$j] : NULL) . "***";	
					}
										                                                                                           					
					$value = $rows_count . (isset($_POST['wdform_'.$i."_hidden_row".$id]) ? $_POST['wdform_'.$i."_hidden_row".$id] : NULL) . '***' . $columns_count . (isset($_POST['wdform_'.$i."_hidden_column".$id]) ? $_POST['wdform_'.$i."_hidden_column".$id] : NULL) . '***' . (isset($_POST['wdform_'.$i."_input_type".$id]) ? $_POST['wdform_'.$i."_input_type".$id] : NULL) . '***' . $input_value . '***matrix***';	
				
					break;
				}
				
			}

			if($type == "type_address")
				if($value == '*#*#*#')
					continue;

	
			if($value) {
				$query = "SELECT id FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id='" . $group_id . "' AND element_label='" . $i . "'";
				$result = $wpdb->get_var($query);
															
				if($result) {					
					$save = $wpdb->update($wpdb->prefix . "formmaker_submits", array(
					  'element_value' => stripslashes($value),
					), array(
					  'group_id' => $group_id,
					  'element_label' => $i
					), array(
					  '%s',
					), array(
					  '%d',
					  '%s'
					));															
				}
				else {
					
					$save = $wpdb->insert($wpdb->prefix . "formmaker_submits", array(
					  'form_id' => $form_id,
					  'element_label' => $i,
					  'element_value' => stripslashes($value),
					  'group_id' => $group_id,
					  'date' => $date,
					  'ip' => $ip
					 ), array(
						 '%d',
						 '%s',
						 '%s',
						 '%d',
						 '%s',
						 '%s'
						)
					);
					
					
				}
			}

	
			
		}
	}
	
    else {	
	
		foreach ($label_id as $key => $label_id_1) {
		  $element_value = (isset($_POST["submission_" . $label_id_1]) ? esc_html(stripslashes($_POST["submission_" . $label_id_1])) : " ");
		  if (isset($_POST["submission_" . $label_id_1])) {
			$query = "SELECT id FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id='" . $id . "' AND element_label='" . $label_id_1 . "'";
			$result = $wpdb->get_var($query);
			if ($label_type[$key] == 'type_file_upload')
			  if ($element_value)
				$element_value = $element_value . "*@@url@@*";
			  if ($result) {
				$save = $wpdb->update($wpdb->prefix . "formmaker_submits", array(
				  'element_value' => stripslashes($element_value),
				), array(
				  'group_id' => $id,
				  'element_label' => $label_id_1
				), array(
				  '%s',
				), array(
				  '%d',
				  '%s'
				)); 
			  }
			  else {
				$save = $wpdb->insert($wpdb->prefix . "formmaker_submits", array(
				  'form_id' => $form_id,
				  'element_label' => $label_id_1,
				  'element_value' => stripslashes($element_value),
				  'group_id' => $id,
				  'date' => $date,
				  'ip' => $ip
				 ), array(
					 '%d',
					 '%s',
					 '%s',
					 '%d',
					 '%s',
					 '%s'
					)
				);
			  }
		  }
		  else {
			$element_value_ch = (isset($_POST["submission_" . $label_id_1 . '_0']) ? esc_html(stripslashes($_POST["submission_" . $label_id_1 . '_0'])) : " ");
			if (isset($_POST["submission_" . $label_id_1 . '_0'])) {
			  for ($z = 0; $z < 21; $z++) {
				$element_value_ch = $_POST["submission_" . $label_id_1 . '_' . $z];
				if (isset($element_value_ch))
				  $element_value = $element_value . $element_value_ch . '***br***';
				else
				  break;
			  }
			  $query = "SELECT id FROM " . $wpdb->prefix . "formmaker_submits WHERE group_id='" . $id . "' AND element_label='" . $label_id_1 . "'";
			  $result = $wpdb->get_var($query);
			  if ($result) {
				$query = "UPDATE " . $wpdb->prefix . "formmaker_submits SET `element_value`='" . stripslashes($element_value) . "' WHERE group_id='" . $id . "' AND element_label='" . $label_id_1 . "'";
				$save = $wpdb->update($wpdb->prefix . "formmaker_submits", array(
					'element_value' => stripslashes($element_value),
				), array(
				  'group_id' => $id,
				  'element_label' => $label_id_1
				), array(
				  '%s',
				), array(
				  '%d',
				  '%s'
				)); 
			  }
			  else {
				$query = "INSERT INTO " . $wpdb->prefix . "formmaker_submits (form_id, element_label, element_value, group_id, date, ip) VALUES('" . $form_id . "', '" . $label_id_1 . "', '" . stripslashes($element_value) . "','" . $id . "', '" . $date . "', '" . $ip . "')";
				$save = $wpdb->insert($wpdb->prefix . "formmaker_submits", array(
					'form_id' => $form_id,
					'element_label' => $label_id_1,
					'element_value' => stripslashes($element_value),
					'group_id' => $id,
					'date' => $date,
					'ip' => $ip
				  ), array(
					 '%d',
					 '%s',
					 '%s',
					 '%d',
					 '%s',
					 '%s'
					)
				);
			  }
			}
		  }
		}		
	}
    if ($save !== FALSE) {
      echo WDW_FMC_Library::message('Submission Succesfully Saved.', 'updated');
    }
    else {
      echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
    }
  }
  
  public function delete($id) {
    global $wpdb;
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);	    
    $query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id="%d"', $id);
    // $elements_col = $wpdb->get_col($wpdb->prepare('SELECT element_value FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id="%d"', $id));
    if ($wpdb->query($query)) {
      // foreach ($elements_col as $element_value) {
        // $destination = str_replace(site_url() . '/', '', $element_value);
        // $destination = str_replace('*@@url@@*', '', $destination);
        // if ($destination) {
          // $destination = ABSPATH . $destination;
          // if (file_exists($destination)) {
             // unlink($destination);
          // }
        // }
      // }
      echo WDW_FMC_Library::message('Item Succesfully Deleted.', 'updated');
    }
    else {
      echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
    }    
    $this->display($form_id);
  }
  
  public function delete_all() {
    global $wpdb;
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? esc_html($_POST['form_id']) : 0);	
    $cid = ((isset($_POST['post']) && $_POST['post'] != '') ? $_POST['post'] : NULL); 
    if (count($cid)) {
	  array_walk($cid, create_function('&$value', '$value = (int)$value;')); 
      $cids = implode(',', $cid);
      $query = 'DELETE FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id IN ( ' . $cids . ' )';
      // $elements_col = $wpdb->get_col('SELECT element_value FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id IN ( ' . $cids . ' )');
      if ($wpdb->query($query)) {
        // foreach ($elements_col as $element_value) {
          // $destination = str_replace(site_url() . '/', '', $element_value);
          // $destination = str_replace('*@@url@@*', '', $destination);
          // if ($destination) {
            // $destination = ABSPATH . $destination;
            // if (file_exists($destination)) {
               // unlink($destination);
            // }
          // }
        // }
        echo WDW_FMC_Library::message('Items Succesfully Deleted.', 'updated');
      }
      else {
        echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
      }
    }
    else {
      echo WDW_FMC_Library::message('You must select at least one item.', 'error');
    }
    $this->display($form_id);
  }

  public function block_ip() {
    global $wpdb;
    $flag = FALSE;
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);	
    $cid = ((isset($_POST['post']) && $_POST['post'] != '') ? $_POST['post'] : NULL); 
    if (count($cid)) {
	  array_walk($cid, create_function('&$value', '$value = (int)$value;'));
      $cids = implode(',', $cid);
      $query = 'SELECT * FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id IN ( '. $cids .' )';
      $rows = $wpdb->get_results($query);
			foreach ($rows as $row) {
				$ips = $wpdb->get_var($wpdb->prepare('SELECT ip FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE ip="%s"', $row->ip));
        $flag = TRUE;
				if (!$ips) {
          $save = $wpdb->insert($wpdb->prefix . 'formmaker_blocked', array(
            'ip' => $row->ip,
          ), array(
            '%s',
          ));
				}
			}
    }
    if ($flag) {
      echo WDW_FMC_Library::message('IPs Succesfully Blocked.', 'updated');
    }
    else {
      echo WDW_FMC_Library::message('You must select at least one item.', 'error');
    }
    $this->display($form_id);
  }

  public function unblock_ip() {
    global $wpdb;
    $flag = FALSE;
    $form_id = ((isset($_POST['form_id']) && esc_html($_POST['form_id']) != '') ? (int)esc_html($_POST['form_id']) : 0);	
    $cid = ((isset($_POST['post']) && $_POST['post'] != '') ? $_POST['post'] : NULL); 
    if (count($cid)) {
	  array_walk($cid, create_function('&$value', '$value = (int)$value;')); 
      $cids = implode(',', $cid);
      $query = 'SELECT * FROM ' . $wpdb->prefix . 'formmaker_submits WHERE group_id IN ( '. $cids .' )';
      $rows = $wpdb->get_results($query);
			foreach ($rows as $row) {
        $flag = TRUE;
				$ips = $wpdb->get_var($wpdb->prepare('SELECT ip FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE ip="%s"', $row->ip));
				if ($ips) {
          $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE ip="%s"', $ips));
				}
			}
    }
    if ($flag) {
      echo WDW_FMC_Library::message('IPs Succesfully Unblocked.', 'updated');
    }
    else {
      echo WDW_FMC_Library::message('You must select at least one item.', 'error');
    }
    $this->display($form_id);
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerBlocked_ips_fmc.php000060400000013404152435511120015152 0ustar00<?php

class FMControllerBlocked_ips_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = WDW_FMC_Library::get('task');
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $message = WDW_FMC_Library::get('message');
    echo WDW_FMC_Library::message_id($message);
    if (method_exists($this, $task)) {
		check_admin_referer('nonce_fmc', 'nonce_fmc');
		$this->$task($id);
    }
    else {
      $this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelBlocked_ips_fmc.php";
    $model = new FMModelBlocked_ips_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewBlocked_ips_fmc.php";
    $view = new FMViewBlocked_ips_fmc($model);
    $view->display();
  }

  public function save() {
    $message = $this->save_db();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function save_db() {
    global $wpdb;
    $id = (isset($_POST['current_id']) ? (int) $_POST['current_id'] : 0);
    $ip = (isset($_POST['ip']) ? esc_html(stripslashes($_POST['ip'])) : '');
    if ($id != 0) {
      $save = $wpdb->update($wpdb->prefix . 'formmaker_blocked', array(
        'ip' => $ip,
      ), array('id' => $id));
    }
    else {
      $save = $wpdb->insert($wpdb->prefix . 'formmaker_blocked', array(
        'ip' => $ip,
      ), array(
				'%s',
      ));
    }
    if ($save !== FALSE) {
      $message = 1;
    }
    else {
      $message = 2;
    }
  }

  public function save_all() {
    global $wpdb;
    $flag = FALSE;
    $ips_id_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker_blocked');
    foreach ($ips_id_col as $ip_id) {
      if (isset($_POST['ip' . $ip_id])) {
        $ip = esc_html(stripslashes($_POST['ip' . $ip_id]));
        if ($ip == '') {
          $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE id="%d"', $ip_id));
        }
        else {
          $flag = TRUE;
          $wpdb->update($wpdb->prefix . 'formmaker_blocked', array(
            'ip' => $ip,
          ), array('id' => $ip_id));
        }
      }
    }
    if ($flag) {
      $message = 1;
    }
    else {
      $message = 0;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function delete($id) {
    global $wpdb;
    $query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE id="%d"', $id);
    if ($wpdb->query($query)) {
      $message = 3;
    }
    else {
      $message = 2;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }
  
  public function delete_all() {
    global $wpdb;
    $flag = FALSE;
    $ips_id_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker_blocked');
    foreach ($ips_id_col as $ip_id) {
      if (isset($_POST['check_' . $ip_id])) {
        $flag = TRUE;
        $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_blocked WHERE id="%d"', $ip_id));
      }
    }
    if ($flag) {
      $message = 5;
    }
    else {
      $message = 2;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFormcontactwdcaptcha.php000060400000005122152435511120016243 0ustar00<?php

class FMControllerFormcontactwdcaptcha {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFormcontactwdcaptcha.php";
    $model = new FMModelFormcontactwdcaptcha();

    require_once WD_FMC_DIR . "/admin/views/FMViewFormcontactwdcaptcha.php";
    $view = new FMViewFormcontactwdcaptcha($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerLicensing_fmc.php000060400000005335152435511120014653 0ustar00<?php

class FMControllerLicensing_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = ((isset($_POST['task'])) ? esc_html(stripslashes($_POST['task'])) : '');
    if (method_exists($this, $task)) {
      $this->$task($id);
    }
    else {
      $this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelLicensing_fmc.php";
    $model = new FMModelLicensing_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewLicensing_fmc.php";
    $view = new FMViewLicensing_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerThemes_fmc.php000060400000017205152435511120014164 0ustar00<?php

class FMControllerThemes_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = WDW_FMC_Library::get('task');
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $message = WDW_FMC_Library::get('message');
    echo WDW_FMC_Library::message_id($message);
    if (method_exists($this, $task)) {
      check_admin_referer('nonce_fmc', 'nonce_fmc');
      $this->$task($id);
    }
    else {
      $this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelThemes_fmc.php";
    $model = new FMModelThemes_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewThemes_fmc.php";
    $view = new FMViewThemes_fmc($model);
    $view->display();
  }

  public function add() {
    require_once WD_FMC_DIR . "/admin/models/FMModelThemes_fmc.php";
    $model = new FMModelThemes_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewThemes_fmc.php";
    $view = new FMViewThemes_fmc($model);
    $view->edit(0, FALSE);
  }

  public function edit() {
    require_once WD_FMC_DIR . "/admin/models/FMModelThemes_fmc.php";
    $model = new FMModelThemes_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewThemes_fmc.php";
    $view = new FMViewThemes_fmc($model);
    // $id = ((isset($_POST['current_id']) && esc_html($_POST['current_id']) != '') ? esc_html($_POST['current_id']) : 0);
    $id = (int)WDW_FMC_Library::get('current_id', 0);
    $view->edit($id, FALSE);
  }

  public function save() {
    $message = $this->save_db();
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function apply() {
    $message = $this->save_db();
    global $wpdb;
    // if (!isset($_POST['current_id']) || (esc_html($_POST['current_id']) == 0) || (esc_html($_POST['current_id']) == '')) {
      
    // }
    $id = (int) $wpdb->get_var('SELECT MAX(`id`) FROM ' . $wpdb->prefix . 'formmaker_themes');
    $current_id = (int)WDW_FMC_Library::get('current_id', $id);
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'edit', 'current_id' => $current_id, 'message' => $message), admin_url('admin.php')));
    // $this->edit();
  }
  
  public function save_db() {
    global $wpdb;
    // $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes( $_POST['current_id'])) : 0);
    $id = (int) WDW_FMC_Library::get('current_id', 0);
    $title = (isset($_POST['title']) ? esc_html(stripslashes( $_POST['title'])) : '');
    $css = (isset($_POST['css']) ? stripslashes(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $_POST['css'])) : '');
    $default = (isset($_POST['default']) ? esc_html(stripslashes( $_POST['default'])) : 0);
    if ($id != 0) {
      $save = $wpdb->update($wpdb->prefix . 'formmaker_themes', array(
        'title' => $title,
        'css' => $css,
        'default' => $default,
      ), array('id' => $id));
    }
    else {
      $save = $wpdb->insert($wpdb->prefix . 'formmaker_themes', array(
        'title' => $title,                       
        'css' => $css,         
        'default' => $default,
      ), array(
        '%s',
        '%s',
        '%d',
      ));
    }
    if ($save !== FALSE) {
      return 1;
    }
    else {
      return 2;
    }
  }

  public function delete($id) {
    global $wpdb;
    $isDefault = $wpdb->get_var($wpdb->prepare('SELECT `default` FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $id));
    if ($isDefault) {
      $message = 4;
    }
    else {
      $query = $wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $id);
      if ($wpdb->query($query)) {
        $message = 3;
      }
      else {
        $message = 2;
      }
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }
  
  public function delete_all() {
    global $wpdb;
    $flag = FALSE;
    $isDefault = FALSE;
    $theme_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'formmaker_themes');
    foreach ($theme_ids_col as $theme_id) {
      if (isset($_POST['check_' . $theme_id])) {
        $isDefault = $wpdb->get_var($wpdb->prepare('SELECT `default` FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $theme_id));
        if ($isDefault) {
          $message = 4;
        }
        else {
          $flag = TRUE;
          $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'formmaker_themes WHERE id="%d"', $theme_id));
        }
      }
    }
    if ($flag) {
      $message = 5;
    }
    else {
      $message = 6;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  public function setdefault($id) {
    global $wpdb;
    $wpdb->update($wpdb->prefix . 'formmaker_themes', array('default' => 0), array('default' => 1));
    $save = $wpdb->update($wpdb->prefix . 'formmaker_themes', array('default' => 1), array('id' => $id));
    if ($save !== FALSE) {
      $message = 7;
    }
    else {
      $message = 2;
    }
    // $this->display();
    $page = WDW_FMC_Library::get('page');
    WDW_FMC_Library::fm_redirect(add_query_arg(array('page' => $page, 'task' => 'display', 'message' => $message), admin_url('admin.php')));
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFormMakerEditCSS_fmc.php000060400000010654152435511120016002 0ustar00<?php

class FMControllerFormMakerEditCSS_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = ((isset($_POST['task'])) ? esc_html($_POST['task']) : '');
    $id = ((isset($_POST['current_id'])) ? (int)esc_html($_POST['current_id']) : 0);
    if (method_exists($this, $task)) {
      $this->$task($id);
    }
    else {
      $this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFormMakerEditCSS_fmc.php";
    $model = new FMModelFormMakerEditCSS_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewFormMakerEditCSS_fmc.php";
    $view = new FMViewFormMakerEditCSS_fmc($model);
    $view->display();
  }

  public function save() {
    $this->update_db();
  }

  public function apply() {
    $this->update_db();
    $this->display();
  }

  public function save_as_new() {
    $this->insert_db();
  }

  public function insert_db() {
    global $wpdb;
    $title = (isset($_POST['title']) ? esc_html(stripslashes( $_POST['title'])) : '');
    $css = (isset($_POST['css']) ? stripslashes(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $_POST['css'])) : '');
    $default = (isset($_POST['default']) ? esc_html(stripslashes( $_POST['default'])) : 0);
    $save = $wpdb->insert($wpdb->prefix . 'formmaker_themes', array(
      'title' => $title,                       
      'css' => $css,         
      'default' => $default,
    ), array(
      '%s',
      '%s',
      '%d',
    ));
  }

  public function update_db() {
    global $wpdb;
    $id = (isset($_POST['current_id']) ? (int) esc_html(stripslashes( $_POST['current_id'])) : 0);
    $title = (isset($_POST['title']) ? esc_html(stripslashes( $_POST['title'])) : '');
    $css = (isset($_POST['css']) ? stripslashes(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $_POST['css'])) : '');
    $default = (isset($_POST['default']) ? esc_html(stripslashes( $_POST['default'])) : 0);
    $save = $wpdb->update($wpdb->prefix . 'formmaker_themes', array(
      'title' => $title,
      'css' => $css,
      'default' => $default,
    ), array('id' => $id));
    if ($save !== FALSE) {
      echo WDW_FMC_Library::message('Item Succesfully Saved.', 'updated');
    }
    else {
      echo WDW_FMC_Library::message('Error. Please install plugin again.', 'error');
    }
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFormcontactwindow.php000060400000005103152435511120015613 0ustar00<?php

class FMControllerFormcontactwindow {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFormcontactwindow.php";
    $model = new FMModelFormcontactwindow();

    require_once WD_FMC_DIR . "/admin/views/FMViewFormcontactwindow.php";
    $view = new FMViewFormcontactwindow($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerGenerete_xml_fmc.php000060400000005076152435511120015360 0ustar00<?php

class FMControllerGenerete_xml_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelGenerete_xml_fmc.php";
    $model = new FMModelGenerete_xml_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewGenerete_xml_fmc.php";
    $view = new FMViewGenerete_xml_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerGenerete_csv_fmc.php000060400000005076152435511120015353 0ustar00<?php

class FMControllerGenerete_csv_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelGenerete_csv_fmc.php";
    $model = new FMModelGenerete_csv_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewGenerete_csv_fmc.php";
    $view = new FMViewGenerete_csv_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerFromipinfoinpopup_fmc.php000060400000005127152435511120016462 0ustar00<?php

class FMControllerFromipinfoinpopup_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $this->display();
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelFromipinfoinpopup_fmc.php";
    $model = new FMModelFromipinfoinpopup_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewFromipinfoinpopup_fmc.php";
    $view = new FMViewFromipinfoinpopup_fmc($model);
    $view->display();
  }

  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}controllers/FMControllerUninstall_fmc.php000060400000006060152435511120014705 0ustar00<?php

class FMControllerUninstall_fmc {
  ////////////////////////////////////////////////////////////////////////////////////////
  // Events                                                                             //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constants                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Variables                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Constructor & Destructor                                                           //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function __construct() {
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Public Methods                                                                     //
  ////////////////////////////////////////////////////////////////////////////////////////
  public function execute() {
    $task = ((isset($_POST['task'])) ? esc_html(stripslashes($_POST['task'])) : '');
    if (method_exists($this, $task)) {
      check_admin_referer('nonce_fmc', 'nonce_fmc');
      $this->$task();
    }
    else {
      $this->display();
    }
  }

  public function display() {
    require_once WD_FMC_DIR . "/admin/models/FMModelUninstall_fmc.php";
    $model = new FMModelUninstall_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewUninstall_fmc.php";
    $view = new FMViewUninstall_fmc($model);
    $view->display();
  }

  public function uninstall() {
    require_once WD_FMC_DIR . "/admin/models/FMModelUninstall_fmc.php";
    $model = new FMModelUninstall_fmc();

    require_once WD_FMC_DIR . "/admin/views/FMViewUninstall_fmc.php";
    $view = new FMViewUninstall_fmc($model);
    $view->uninstall();
  }
  ////////////////////////////////////////////////////////////////////////////////////////
  // Getters & Setters                                                                  //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Private Methods                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////
  ////////////////////////////////////////////////////////////////////////////////////////
  // Listeners                                                                          //
  ////////////////////////////////////////////////////////////////////////////////////////
}

Al-HUWAITI Shell