define("app/services/configService",["angular","cjt/io/api","cjt/io/uapi-request","cjt/io/uapi"],(function(e,t,n,i){e.module("App").factory("configService",["$q",function(e){return{fetchBasicList:function(i,o){var a=e.defer(),r=new n.Class;return r.initialize("LangPHP","php_ini_get_user_basic_directives"),r.addArgument("type",i),"home"!==i&&r.addArgument("vhost",o),t.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?a.resolve(e.data):a.reject(e.error)})),a.promise},getHandlerForDomain:function(i,o){var a=e.defer(),r=new n.Class;return r.initialize("LangPHP","php_get_domain_handler"),r.addArgument("type",i),"home"!==i&&r.addArgument("vhost",o),t.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?a.resolve(e.data):a.reject(e.error)})),a.promise},applySettings:function(i,o,a){var r=e.defer(),s=new n.Class;return s.initialize("LangPHP","php_ini_set_user_basic_directives"),"home"!==i&&s.addArgument("vhost",o),s.addArgument("type",i),void 0!==a&&a.length>0&&a.forEach((function(e,t){s.addArgument("directive-"+t,e.key+":"+e.value)})),t.promise(s.getRunArguments()).done((function(e){(e=e.parsedResponse).status?r.resolve(e.data):r.reject(e.error)})),r.promise},fetchContent:function(i,o){var a=e.defer(),r=new n.Class;return r.initialize("LangPHP","php_ini_get_user_content"),r.addArgument("type",i),"home"!==i&&r.addArgument("vhost",o),t.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?a.resolve(e.data.content):a.reject(e.error)})),a.promise},saveIniContent:function(i,o,a){var r=e.defer(),s=new n.Class;return s.initialize("LangPHP","php_ini_set_user_content"),s.addArgument("content",i),s.addArgument("type",o),"home"!==o&&s.addArgument("vhost",a),t.promise(s.getRunArguments()).done((function(e){(e=e.parsedResponse).status?r.resolve(e.data):r.reject(e.error)})),r.promise}}}])})),define("app/views/basicMode",["angular","lodash","cjt/util/locale","uiBootstrap","cjt/directives/alertList","cjt/directives/spinnerDirective","cjt/decorators/growlDecorator","cjt/services/alertService","app/services/configService","cjt/directives/actionButtonDirective"],(function(e,t,n){return e.module("App").controller("basicMode",["$scope","$location","configService","$routeParams","$timeout","spinnerAPI","alertService","growl",function(e,i,o,a,r,s,c,l){var p,u=[],d=!1;e.noIniPaths=!0,e.txtInFirstOption=n.maketext("[comment,used for highlight in select option]-- Not Available --[comment,used for highlight in select option]"),e.selectedIniPath={type:"",name:""},e.iniPathNames=[],e.loadingDirectiveList=!1,e.showEmptyMessage=!1,e.knobLabel=" ";e.loadDirectives=function(){if(c.clear(),e.selectedIniPath.type){s.start("loadingSpinner");var i=e.selectedIniPath;e.loadingDirectiveList=!0,d=!1;var a=m(e.selectedIniPath);return"home"===a.type?a.inifullpath=a.homedir+"/"+a.path:"vhost"===a.type&&(a.inifullpath=a.documentroot+"/"+a.path),e.currentIniPathInfo=a,o.fetchBasicList(i.type,i.name).then((function(a){if(void 0!==a.directives&&a.directives.length>0){var r=a.directives;return o.getHandlerForDomain(i.type,i.name).then((function(i){"suphp"!==i.php_handler&&(r=t.filter(r,(function(e){return"PHP_INI_SYSTEM"!==e.php_ini_mode}))),e.directiveList=r.map((function(e){e.toggleValue="On"===e.value;var t=e.default_value;return void 0!==e.cpanel_default&&null!==e.cpanel_default&&(t=e.cpanel_default),"boolean"===e.type&&(t="1"===e.default_value?n.maketext("Enabled"):n.maketext("Disabled")),e.default_text=n.maketext("[asis,PHP] Default: [output,class,_1,defaultValue]",t),e}))}),(function(e){c.add({type:"danger",message:e,closeable:!0,replace:!1,group:"multiphpIniEditor"})}))}}),(function(e){c.add({type:"danger",message:e,closeable:!0,replace:!1,group:"multiphpIniEditor"})})).then((function(){e.loadingDirectiveList=!1,s.stop("loadingSpinner")})).finally((function(){s.stop("loadingSpinner"),e.showEmptyMessage=""!==e.selectedIniPath&&e.directiveList.length<=0}))}e.directiveList=[],e.showEmptyMessage=!1};var h=function(){d||(d=!0,l.info(n.maketext("You must click “[_1]” to apply the new changes.",n.maketext("Apply")),{ttl:-1,onopen:function(){p=this}}))};e.toggle_status=function(e){"On"===e.value?(e.value="Off",e.toggleValue=!1):(e.value="On",e.toggleValue=!0),h()},e.directiveTextChange=function(t){h();var i=t.type,o=t.value||"",a=!0,r="";if("integer"===i){var s="[~!]?\\s*E_(?:(?:(?:CORE_|COMPILE_|USER_)?(?:ERROR|WARNING))|(?:USER_)?(?:NOTICE|DEPRECATED)|PARSE|STRICT|RECOVERABLE_ERROR|ALL)",c=new RegExp("^\\s*"+s+"(?:\\s*[&|^]\\s*"+s+")*$");/^-?\d+[kmg]?$/i.test(o)||c.test(o)?a=!0:(a=!1,r=n.maketext("You must provide either an integer value, a [output,url,_1,shorthand byte,target,blank,title,shorthand byte documentation], or a [output,url,_2,predefined constant,target,blank,title,predefined constant documentation].","http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes","http://php.net/manual/en/errorfunc.constants.php"))}else"float"===i&&(/^-?\d+(?:\.\d*)?$/.test(o)?a=!0:(a=!1,r=n.maketext("You must provide a valid float value.")));e.basicModeForm["txt"+t.key].$setValidity("pattern",a),t.validationMsg=r},e.disableApply=function(){return e.noIniPaths||!e.selectedIniPath.type||!e.basicModeForm.$valid},e.requiredValidation=function(e){return"string"!==e.type&&"boolean"!==e.type},e.applyPhpSettings=function(){if(e.basicModeForm.$valid)return c.clear(),d=!1,void 0!==p&&p.destroy(),o.applySettings(e.selectedIniPath.type,e.selectedIniPath.name,e.directiveList).then((function(e){void 0!==e&&c.add({type:"success",message:n.maketext("Successfully applied the settings."),closeable:!0,replace:!1,autoClose:1e4,group:"multiphpIniEditor"})}),(function(e){c.add({type:"danger",message:t.unescape(e),closeable:!0,replace:!1,group:"multiphpIniEditor"})}))};var m=function(e){return t.find(u,(function(t){return"home"===e.type&&"home"===t.type||("vhost"===e.type&&e.name===t.vhost||void 0)}))};e.$on("$viewContentLoaded",(function(){c.clear();var i,o,a=PAGE.php_ini_data;(e.localeIsRTL=!!PAGE.locale_is_RTL,!a.status&&a.errors.length>0)?a.errors.forEach((function(e){c.add({type:"danger",message:e,replace:!1,closeable:!0,group:"multiphpIniEditor"})})):((i=a.data.paths).length>0&&(u=i,t.each(i,(function(t){"home"===t.type||t.main_domain?t.main_domain&&(o=t.vhost):e.iniPathNames.push({type:t.type,name:t.vhost})})),e.iniPathNames=t.sortBy(e.iniPathNames,"name"),e.iniPathNames.unshift({type:"vhost",name:o}),e.iniPathNames.unshift({type:"home",name:"Home Directory"})),e.iniPathNames.length>0&&(e.noIniPaths=!1,e.txtInFirstOption=n.maketext("[comment,used for highlight in select option]-- Select a location --[comment,used for highlight in select option]")))}))}])})),define("app/views/editorMode",["angular","lodash","cjt/util/locale","jquery","ace","uiBootstrap","cjt/directives/alertList","cjt/services/alertService","cjt/decorators/growlDecorator","app/services/configService"],(function(e,t,n,i){return e.module("App").controller("editorMode",["$scope","$location","$routeParams","$timeout","spinnerAPI","alertService","growl","configService",function(e,o,a,r,s,c,l,p){var u,d,h=[],m=!1;e.noIniPaths=!0,e.txtInFirstOption=n.maketext("[comment,used for highlight in select option]-- Not Available --[comment,used for highlight in select option]"),e.selectedIniPath={type:"",name:""},e.iniPathNames=[],e.processingEditor=!1;var g=function(t){void 0!==d&&d.setReadOnly(t),e.processingEditor=t};e.loadContent=function(){if(c.clear(),e.selectedIniPath.type){s.start("loadingSpinner");var o=e.selectedIniPath;g(!0),m=!1;var a=(r=e.selectedIniPath,t.find(h,(function(e){return"home"===r.type&&"home"===e.type||"vhost"===r.type&&r.name===e.vhost||void 0})));return"home"===a.type?a.inifullpath=a.homedir+"/"+a.path:"vhost"===a.type&&(a.inifullpath=a.documentroot+"/"+a.path),e.currentIniPathInfo=a,p.fetchContent(o.type,o.name).then((function(t){if("undefined"!==t){""===t&&c.add({type:"info",message:n.maketext("The [asis,INI] content does not exist. You may add new content."),closeable:!0,replace:!1,group:"multiphpIniEditor"});var o=i("<div/>").html(t).text();void 0===d&&((d=ace.edit("editor")).$blockScrolling=1/0,d.setShowPrintMargin(!1)),d.focus(),d.scrollToRow(0),d.setTheme("ace/theme/chrome");var a=ace.createEditSession(o);d.setSession(a),void 0!==a&&(a.setMode("ace/mode/ini"),d.on("change",e.informUser))}}),(function(e){c.add({type:"danger",message:e,closeable:!0,replace:!1,group:"multiphpIniEditor"})})).then((function(){g(!1)})).finally((function(){s.stop("loadingSpinner")}))}var r},e.informUser=function(){m||(m=!0,l.info(n.maketext("You must click “[_1]” to apply the new changes.",n.maketext("Save")),{ttl:-1,onopen:function(){u=this}}))},e.save=function(){c.clear(),m=!1,void 0!==u&&u.destroy(),g(!0);var i=t.escape(d.getSession().getValue());return p.saveIniContent(i,e.selectedIniPath.type,e.selectedIniPath.name).then((function(e){void 0!==e&&c.add({type:"success",message:n.maketext("Successfully saved the changes."),closeable:!0,replace:!1,autoClose:1e4,group:"multiphpIniEditor"})}),(function(e){c.add({type:"danger",message:t.escape(e),closeable:!0,replace:!1,group:"multiphpIniEditor"})})).then((function(){g(!1)}))};e.$on("$viewContentLoaded",(function(){c.clear();var i,o,a=PAGE.php_ini_data;!a.status&&a.errors.length>0&&a.errors.forEach((function(e){c.add({type:"danger",message:e,replace:!1,closeable:!0,group:"multiphpIniEditor"})}));(i=a.data.paths).length>0&&(h=i,t.each(i,(function(t){"home"===t.type||t.main_domain?t.main_domain&&(o=t.vhost):e.iniPathNames.push({type:t.type,name:t.vhost})})),e.iniPathNames=t.sortBy(e.iniPathNames,"name"),e.iniPathNames.unshift({type:"vhost",name:o}),e.iniPathNames.unshift({type:"home",name:"Home Directory"})),e.iniPathNames.length>0&&(e.noIniPaths=!1,e.txtInFirstOption=n.maketext("[comment,used for highlight in select option]-- Select a location --[comment,used for highlight in select option]"))}))}])})),define("app/index",["angular","jquery","lodash","cjt/core","cjt/modules","cjt/services/alertService","cjt/directives/alert","cjt/directives/alertList","ngRoute","uiBootstrap","ngAnimate"],(function(e,t,n,i){return function(){return e.module("App",["ngRoute","ui.bootstrap","ngAnimate","cjt2.cpanel"]),require(["cjt/bootstrap","app/views/basicMode","app/views/editorMode"],(function(t){var n=e.module("App");n.firstLoad={phpAccountList:!0},n.config(["$routeProvider","$locationProvider",function(e,t){e.when("/basic",{controller:"basicMode",templateUrl:i.buildFullPath("multiphp_ini_editor/views/basicMode.html.tt"),reloadOnSearch:!1}),e.when("/editor",{controller:"editorMode",templateUrl:i.buildFullPath("multiphp_ini_editor/views/editorMode.html.tt"),reloadOnSearch:!1}),e.otherwise({redirectTo:"/basic"})}]),n.run(["$rootScope","$location","growlMessages",function(e,t,n){e.$on("$routeChangeStart",(function(){e.currentRoute=t.path(),n.destroyAllMessages()}))}]),t("#content","App")}))}}));