diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index 51cebdfaa..8103ce6bd 100755 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -35,25 +35,25 @@ class headPublisher { var $maborakLoaderFiles = array (); var $scriptFiles = array (); var $leimnudLoad = array (); - + /* extJsSkin init coreLoad flag*/ var $extJsInit = 'false'; - + /* extJsSkin store the current skin for the ExtJs*/ var $extJsSkin = ''; - + /* extJsScript Array, to store the file to be include */ var $extJsScript = array (); - + /* extJsLibrary Array, to store extended ExtJs lybraries */ var $extJsLibrary = array (); - + /* extJsContent Array, to store the file to be include in the skin content */ var $extJsContent = array (); - + /* extVariable array, to store the variables generated in PHP, and used in JavaScript */ var $extVariable = array (); - + var $leimnudInitString = ' var leimnud = new maborak(); leimnud.make({ zip:true, @@ -70,25 +70,25 @@ class headPublisher { }catch(e){}'; var $disableHeaderScripts = false; var $title = ''; - + /** * Function headPublisher * @author David S. Callizaya S. * @access public * @return string */ - + private function __construct() { $this->addScriptFile ( "/js/maborak/core/maborak.js" ); } - + function &getSingleton() { if (self::$instance == NULL) { self::$instance = new headPublisher ( ); } return self::$instance; } - + /** * Function setTitle * @author David S. Callizaya S. @@ -100,7 +100,7 @@ class headPublisher { function setTitle($title) { $this->title = $title; } - + /** * Function addMaborakFile * @access public @@ -114,7 +114,7 @@ class headPublisher { else $this->maborakFiles [] = $filename; } - + /** * Function addScriptFile * @author David S. Callizaya S. @@ -129,7 +129,7 @@ class headPublisher { if ($LoadType == 2) $this->leimnudLoad [$url] = $url; } - + /** * Function addInstanceModule * @author David S. Callizaya S. @@ -138,11 +138,11 @@ class headPublisher { * @parameter string module * @return string */ - + function addInstanceModule($instance, $module) { $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Instance:" . $instance . ",Type:'module'});\n"; } - + /** * Function addClassModule * @author David S. Callizaya S. @@ -154,7 +154,7 @@ class headPublisher { function addClassModule($class, $module) { $this->headerScript .= "leimnud.Package.Load('" . $module . "',{Class:" . $class . ",Type:'module'});\n"; } - + /** * Function addScriptCode * @author David S. Callizaya S. @@ -165,7 +165,7 @@ class headPublisher { function addScriptCode($script) { $this->headerScript .= $script; } - + /** * Function printHeader * @author David S. Callizaya S. @@ -185,20 +185,20 @@ class headPublisher { if ($this->disableHeaderScripts) return ''; - // available js-calendar languages array + // available js-calendar languages array $availableJsCalendarLang = array('ca', 'cn', 'cz', 'de', 'en', 'es', 'fr', 'it', 'jp', 'nl', 'pl', 'pt', 'ro', 'ru', 'sv'); - + // get the system language without locale $sysLang = explode('-', SYS_LANG); $sysLang = $sysLang[0]; - + // verify if the requested lang by the system is supported by js-calendar library, if not set english by default - $sysLang = in_array($sysLang, $availableJsCalendarLang) ? $sysLang : 'en'; - + $sysLang = in_array($sysLang, $availableJsCalendarLang) ? $sysLang : 'en'; + $this->addScriptFile ( "/js/widgets/js-calendar/unicode-letter.js" ); $this->addScriptFile ( "/js/widgets/js-calendar/lang/".$sysLang.".js" ); $this->addScriptFile ( "/js/widgets/js-calendar/lang/en.js" ); - + $head = ''; $head .= '' . $this->title . "\n"; foreach ( $this->scriptFiles as $file ) @@ -211,7 +211,7 @@ class headPublisher { $head .= "\n"; return $head; } - + /** * Function printRawHeader * Its prupose is to load el HEADs initialization javascript @@ -245,7 +245,7 @@ class headPublisher { //$head .= "\n"; return $head; } - + /** * Function clearScripts * Its prupose is to clear all the scripts of the header. @@ -260,7 +260,7 @@ class headPublisher { $this->leimnudInitString = ''; $this->headerScript = ''; } - + /** * Function includeExtJs * with this function we are using the ExtJs library, this library is not compatible with @@ -295,31 +295,31 @@ class headPublisher { //$head .= " \n"; $head .= " \n"; - + if (! isset ( $this->extJsSkin ) || $this->extJsSkin == '') { $this->extJsSkin = 'xtheme-gray'; //$this->extJsSkin = 'gtheme'; } - + //$head .= $this->getExtJsStylesheets(); $head .= $this->getExtJsScripts(); $head .= $this->getExtJsVariablesScript(); - + return $head; } - + function getExtJsStylesheets($skinName){ $script = " \n"; /* $script .= " \n"; $script .= " \n"; - + // - + //new interactive css decorator $script .= " \n"; $script .= " \n"; @@ -333,10 +333,10 @@ class headPublisher { $script .= " \n"; } } - + return $script; } - + function getExtJsScripts(){ $script = ''; if (isset ( $this->extJsScript ) && is_array ( $this->extJsScript )) { @@ -346,10 +346,10 @@ class headPublisher { } return $script; } - + function getExtJsVariablesScript(){ $script = ''; - + if (count ( $this->extVariable ) > 0) { $script = "\n"; } - + return $script; } - + /** * add a ExtJS extended library * @@ -387,7 +387,7 @@ class headPublisher { } array_push ( $this->extJsLibrary, $library ); } - + /** * Function setExtSkin * with this function we are using the ExtJs library, this library is not compatible with @@ -401,7 +401,7 @@ class headPublisher { function setExtSkin($skin) { $this->extJsSkin = $skin; } - + /** * Function addExtJsScript * adding a javascript file .js @@ -418,10 +418,10 @@ class headPublisher { * @return string */ function addExtJsScript($filename, $debug = false, $isExternal=false) { - + $sPath = PATH_TPL; //if the template file doesn't exists, then try with the plugins folders - + if (! is_file ( $sPath . $filename . ".js" )) { $aux = explode ( PATH_SEP, $filename ); @@ -442,7 +442,7 @@ class headPublisher { if (! file_exists ( $jsFilename )) { return; } - + $mtime = filemtime ( $jsFilename ); G::mk_dir ( PATH_C . 'ExtJs' ); if ($debug) { @@ -453,7 +453,7 @@ class headPublisher { else { $cacheName = md5 ( $mtime . $jsFilename ); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $cacheName . '.js'; - + if (! file_exists ( $cacheFilename )) { require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); $content = JSMin::minify ( file_get_contents ( $jsFilename ) ); @@ -468,9 +468,9 @@ class headPublisher { $oPluginRegistry = & PMPluginRegistry::getSingleton(); $pluginJavascripts = $oPluginRegistry->getRegisteredJavascriptBy($filename); if (count($pluginJavascripts) > 0) { - $jsPluginCacheName = ''; if ($debug) { foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; if (substr($pluginJsFile, -3) != '.js') { $pluginJsFile .= '.js'; } @@ -478,12 +478,16 @@ class headPublisher { if (file_exists(PATH_PLUGINS . $pluginJsFile)) { $jsPluginCacheName = str_replace ( '/', '_', str_replace('.js', '', $pluginJsFile) ); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName.".js"; - file_put_contents ( $cacheFilename, file_get_contents ( PATH_PLUGINS . $pluginJsFile ) ); + file_put_contents ( $cacheFilename, file_get_contents ( PATH_PLUGINS . $pluginJsFile ) ); + } + if ($jsPluginCacheName != '') { + $this->extJsScript [] = '/extjs/' . $jsPluginCacheName; } } } else { foreach ($pluginJavascripts as $pluginJsFile) { + $jsPluginCacheName = ''; if (substr($pluginJsFile, -3) !== '.js') { $pluginJsFile .= '.js'; } @@ -491,23 +495,23 @@ class headPublisher { $mtime = filemtime ( PATH_PLUGINS . $pluginJsFile ); $jsPluginCacheName = md5 ( $mtime . $pluginJsFile ); $cacheFilename = PATH_C . 'ExtJs' . PATH_SEP . $jsPluginCacheName . '.js'; - + if (! file_exists ( $cacheFilename )) { require_once (PATH_THIRDPARTY . 'jsmin/jsmin.php'); $content = JSMin::minify ( file_get_contents ( PATH_PLUGINS . $pluginJsFile ) ); file_put_contents ( $cacheFilename, $content ); } } + if ($jsPluginCacheName != '') { + $this->extJsScript [] = '/extjs/' . $jsPluginCacheName; + } } } - if ($jsPluginCacheName != '') { - $this->extJsScript [] = '/extjs/' . $jsPluginCacheName; - } } //end hook for registered javascripts from plugins - + } - + /** * Function AddContent * adding a html file .html. @@ -522,7 +526,7 @@ class headPublisher { function AddContent($templateHtml) { $this->extJsContent [] = $templateHtml; } - + /** * Function assign * assign a STRING value to a JS variable @@ -535,7 +539,7 @@ class headPublisher { function Assign($variable, $value) { $this->extVariable [] = array ('name' => $variable, 'value' => $value, 'type' => 'string' ); } - + /** * Function assignNumber * assign a Number value to a JS variable @@ -573,7 +577,7 @@ class headPublisher { } } } - + $template = new TemplatePower ( $sPath . $file . '.html' ); $template->prepare (); $body .= $template->getOutputContent (); @@ -602,7 +606,7 @@ class headPublisher { } return $sJson; } - + /** * Function disableHeaderScripts * this function sets disableHeaderScripts to true diff --git a/workflow/engine/templates/authSources/authSourcesList.js b/workflow/engine/templates/authSources/authSourcesList.js index de38765de..3b60194dc 100755 --- a/workflow/engine/templates/authSources/authSourcesList.js +++ b/workflow/engine/templates/authSources/authSourcesList.js @@ -58,49 +58,50 @@ var comboStatusStore; var editForm; var contextMenu; var w; - +var actionButtons; + Ext.onReady(function(){ Ext.QuickTips.init(); - + pageSize = parseInt(CONFIG.pageSize); - + newButton = new Ext.Action({ text: _('ID_NEW'), iconCls: 'button_menu_ext ss_sprite ss_add', handler: NewAuthSource }); - + editButton = new Ext.Action({ text: _('ID_EDIT'), iconCls: 'button_menu_ext ss_sprite ss_pencil', handler: EditAuthSource, - disabled: true + disabled: true }); - + deleteButton = new Ext.Action({ text: _('ID_DELETE'), iconCls: 'button_menu_ext ss_sprite ss_delete', handler: DeleteAuthSource, disabled: true }); - + usersButton = new Ext.Action({ text: _('ID_IMPORT_USERS'), iconCls: 'button_menu_ext ss_sprite ss_user_add', handler: ImportUsers, disabled: true - + }); - + searchButton = new Ext.Action({ text: _('ID_SEARCH'), handler: DoSearch }); - + contextMenu = new Ext.menu.Menu({ items: [editButton, deleteButton,'-',usersButton] }); - + searchText = new Ext.form.TextField ({ id: 'searchText', ctCls:'pm_search_text_field', @@ -119,26 +120,45 @@ Ext.onReady(function(){ } } }); - + clearTextButton = new Ext.Action({ text: 'X', ctCls:'pm_search_x_button', handler: GridByDefault }); - - + + actionButtons = _addPluginActions([newButton, '-', editButton, deleteButton, '-', usersButton, {xtype: 'tbfill'}, searchText, clearTextButton, searchButton]); + smodel = new Ext.grid.RowSelectionModel({ singleSelect: true, listeners:{ - rowselect: function(sm){ + rowselect: function(sm, index, record){ editButton.enable(); deleteButton.enable(); usersButton.enable(); + if (typeof(_rowselect) !== 'undefined') { + if (Ext.isArray(_rowselect)) { + for (var i = 0; i < _rowselect.length; i++) { + if (Ext.isFunction(_rowselect[i])) { + _rowselect[i](sm, index, record); + } + } + } + } }, - rowdeselect: function(sm){ + rowdeselect: function(sm, index, record){ editButton.disable(); deleteButton.disable(); usersButton.disable(); + if (typeof(_rowdeselect) !== 'undefined') { + if (Ext.isArray(_rowdeselect)) { + for (var i = 0; i < _rowdeselect.length; i++) { + if (Ext.isFunction(_rowdeselect[i])) { + _rowdeselect[i](sm, index, record); + } + } + } + } } } }); @@ -167,7 +187,7 @@ Ext.onReady(function(){ ] }) }); - + cmodel = new Ext.grid.ColumnModel({ defaults: { width: 50, @@ -183,13 +203,13 @@ Ext.onReady(function(){ {header: _('ID_ACTIVE_USERS'), dataIndex: 'CURRENT_USERS', width: 90, hidden: false, align: 'center'} ] }); - + storePageSize = new Ext.data.SimpleStore({ fields: ['size'], data: [['20'],['30'],['40'],['50'],['100']], autoLoad: true }); - + comboPageSize = new Ext.form.ComboBox({ typeAhead : false, mode : 'local', @@ -207,9 +227,9 @@ Ext.onReady(function(){ } } }); - + comboPageSize.setValue(pageSize); - + bbarpaging = new Ext.PagingToolbar({ pageSize: pageSize, store: store, @@ -218,7 +238,7 @@ Ext.onReady(function(){ emptyMsg: _('ID_GRID_PAGE_NO_AUTHENTICATION_MESSAGE'), items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize] }); - + infoGrid = new Ext.grid.GridPanel({ region: 'center', layout: 'fit', @@ -239,7 +259,7 @@ Ext.onReady(function(){ store: store, cm: cmodel, sm: smodel, - tbar: [newButton, '-', editButton, deleteButton,'-',usersButton, {xtype: 'tbfill'}, searchText,clearTextButton,searchButton], + tbar: actionButtons, bbar: bbarpaging, listeners: { rowdblclick: EditAuthSource, @@ -254,22 +274,22 @@ Ext.onReady(function(){ emptyText: _('ID_NO_RECORDS_FOUND') }) }); - - infoGrid.on('rowcontextmenu', + + infoGrid.on('rowcontextmenu', function (grid, rowIndex, evt) { var sm = grid.getSelectionModel(); sm.selectRow(rowIndex, sm.isSelected(rowIndex)); }, this ); - - infoGrid.on('contextmenu', + + infoGrid.on('contextmenu', function (evt) { evt.preventDefault(); - }, + }, this ); - + infoGrid.addListener('rowcontextmenu',onMessageContextMenu,this); infoGrid.store.load(); @@ -301,7 +321,7 @@ GridByDefault = function(){ //Do Search Function DoSearch = function(){ - infoGrid.store.load({params: {textFilter: searchText.getValue()}}); + infoGrid.store.load({params: {textFilter: searchText.getValue()}}); }; //Update Page Size Configuration @@ -365,11 +385,11 @@ DeleteAuthSource = function(){ viewport.getEl().unmask(); } }); - } + } }); - + }else{ - PMExt.error(_('ID_AUTH_SOURCES'),_('ID_MSG_CANNOT_DELETE_AUTHENTICATION')); + PMExt.error(_('ID_AUTH_SOURCES'),_('ID_MSG_CANNOT_DELETE_AUTHENTICATION')); } }, failure: function(r,o){ @@ -386,3 +406,48 @@ ImportUsers = function(){ location.href = 'authSources_SearchUsers?sUID=' +rowSelected.data.AUTH_SOURCE_UID; } }; + +// Mover a un archivo más genérico - Start +var _pluginActionButtons = []; +var _rowselect = []; +var _rowdeselect = []; + +var _addPluginActions = function(defaultActionButtons) { + try { + if (Ext.isArray(_pluginActionButtons)) { + if (_pluginActionButtons.length > 0) { + var positionToInsert = _tbfillPosition(defaultActionButtons); + var leftActionButtons = defaultActionButtons.slice(0, positionToInsert); + var rightActionButtons = defaultActionButtons.slice(positionToInsert, defaultActionButtons.length - 1); + return leftActionButtons.concat(_pluginActionButtons.concat(rightActionButtons)); + } + else { + return defaultActionButtons; + } + } + else { + return defaultActionButtons; + } + } + catch (error) { + return defaultActionButtons; + } +}; + +var _tbfillPosition = function(actionButtons) { + try { + for (var i = 0; i < actionButtons.length; i++) { + if (Ext.isObject(actionButtons[i])) { + if (actionButtons[i].xtype == 'tbfill') { + return i; + } + } + } + return i; + } + catch (error) { + return 0; + } +}; + +// Mover a un archivo más genérico - End \ No newline at end of file