Cherry pick of PM-3193 to branch 3.0.1.4

This commit is contained in:
Julio Cesar Laura
2015-09-16 14:21:16 -04:00
committed by Enrique Ponce De Leon
parent 05ef7afbed
commit 0476ca2bba
4 changed files with 182 additions and 66 deletions

View File

@@ -379,6 +379,17 @@ class PMPlugin
$oPluginRegistry =& PMPluginRegistry::getSingleton();
$oPluginRegistry->enableRestService($this->sNamespace, $enable);
}
/**
* With this function we can register new options to designer menu
* param string $menuOptionsFile
* @return void
*/
public function registerDesignerNewOption($menuOptionsFile)
{
$oPluginRegistry =& PMPluginRegistry::getSingleton();
$oPluginRegistry->registerDesignerNewOption($this->sNamespace, $menuOptionsFile);
}
}
class menuDetail
@@ -718,3 +729,21 @@ class cronFile
$this->cronFile = $cronFile;
}
}
class menuOptionFile
{
public $namespace;
public $menuOptionFile;
/**
* This function is the constructor of the cronFile class
* param string $namespace
* param string $menuOptionFile
* @return void
*/
public function __construct($namespace, $menuOptionFile)
{
$this->namespace = $namespace;
$this->menuOptionFile = $menuOptionFile;
}
}

View File

@@ -101,6 +101,7 @@ class PMPluginRegistry
private $_aTaskExtendedProperties = array ();
private $_aDashboardPages = array ();
private $_aCronFiles = array ();
private $_aDesignerMenuFiles = array ();
/**
* Registry a plugin javascript to include with js core at same runtime
@@ -391,6 +392,11 @@ class PMPluginRegistry
unset( $this->_aDashboardPages[$key] );
}
}
foreach ($this->_aDesignerMenuFiles as $key => $detail) {
if ($detail->namespace == $sNamespace) {
unset( $this->_aDesignerMenuFiles[$key] );
}
}
//unregistering javascripts from this plugin
$this->unregisterJavascripts( $sNamespace );
@@ -1601,4 +1607,35 @@ class PMPluginRegistry
throw $e;
}
}
/**
* Register new options to designer menu
*
* @param unknown_type $namespace
* @param unknown_type $cronFile
*/
public function registerDesignerNewOption ($namespace, $menuOptionFile)
{
$found = false;
foreach ($this->_aDesignerMenuFiles as $row => $detail) {
if ($menuOptionFile == $detail->menuOptionFile && $namespace == $detail->namespace) {
$detail->menuOptionFile = $menuOptionFile;
$found = true;
}
}
if (!$found) {
$menuOptionFile = new menuOptionFile( $namespace, $menuOptionFile );
$this->_aDesignerMenuFiles[] = $menuOptionFile;
}
}
/**
* Return all designer menu Option files registered
*
* @return array
*/
public function getDesignerNewOption()
{
return $this->_aDesignerMenuFiles;
}
}

View File

@@ -38,6 +38,90 @@ if (preg_match("/^([\d\.]+).*$/", System::getVersion(), $arrayMatch)) {
$arrayImportFileExtension = array("pm", "pmx", "bpmn");
$arrayMenuNewOption = array("pm" => true, "bpmn" => true);
/*options menu*/
$arrayMenuNew = array();
$mnuNewBpmnProject = new stdClass();
$mnuNewBpmnProject->text = G::LoadTranslation("ID_NEW_BPMN_PROJECT");
$mnuNewBpmnProject->iconCls = "silk-add";
$mnuNewBpmnProject->icon = "";
$mnuNewBpmnProject->newProcessType = 'newProcess({type:"bpmnProject",title:"'.$mnuNewBpmnProject->text.'"})';
$mnuNewProject = new stdClass();
$mnuNewProject->text = G::LoadTranslation("ID_NEW_PROJECT");
$mnuNewProject->iconCls = "silk-add";
$mnuNewProject->icon = "";
$mnuNewProject->newProcessType = 'newProcess({type:"classicProject",title:"'.$mnuNewProject->text.'"})';
$menuOption = array("pm" => $mnuNewProject, "bpmn" => $mnuNewBpmnProject);
foreach($arrayMenuNewOption as $type => $val) {
if($val) {
array_push($arrayMenuNew, $menuOption[$type]);
}
}
/*right click menu*/
$contexMenuRightClick = array(
(object)array(
"text" => G::LoadTranslation("ID_EDIT"),
"iconCls" => "button_menu_ext ss_sprite ss_pencil",
"handler" => "editProcess()"
),
(object)array(
"id" => "activator2",
"text" => "",
"icon" => "",
"handler" => "activeDeactive()"
),
(object)array(
"id" => "debug",
"text" => "",
"handler" => "enableDisableDebug()"
),
(object)array(
"text" => G::LoadTranslation("ID_DELETE"),
"iconCls" => "button_menu_ext ss_sprite ss_cross",
"handler" => "deleteProcess()"
),
(object)array(
"text" => G::LoadTranslation("ID_EXPORT"),
"icon" => "/images/export.png",
"handler" => "exportProcess()"
),
(object)array(
"id" => "mnuGenerateBpmn",
"text" => G::LoadTranslation("ID_GENERATE_BPMN_PROJECT"),
"iconCls" => "button_menu_ext ss_sprite ss_page_white_go",
"hidden" => true,
"handler" => "generateBpmn()"
)
);
/*end right click menu*/
/*get registered options from plugin*/
$oPluginRegistry =& PMPluginRegistry::getSingleton();
$fromPlugin = $oPluginRegistry->getDesignerNewOption();
$jsFromPlugin = false;
foreach($fromPlugin as $menuOptionFile) {
$menuOptionsFromPlugin = include_once($menuOptionFile->menuOptionFile);
if(isset($menuOptionsFromPlugin)) {
if(is_array($menuOptionsFromPlugin) && sizeof($menuOptionsFromPlugin)) {
if(is_array($menuOptionsFromPlugin[0]) && sizeof($menuOptionsFromPlugin[0])) {
$arrayMenuNew = array_merge($arrayMenuNew,$menuOptionsFromPlugin[0]);
}
if(is_array($menuOptionsFromPlugin[1]) && sizeof($menuOptionsFromPlugin[1])) {
$contexMenuRightClick = array_merge($contexMenuRightClick,$menuOptionsFromPlugin[1]);
}
if(isset($menuOptionsFromPlugin[2])) {
if(file_exists(PATH_PLUGINS.implode("/",array_slice(explode("/",$menuOptionsFromPlugin[2]),2)))) {
$jsFromPlugin = $menuOptionsFromPlugin[2];
}
}
}
}
}
/*end get registered options from plugin*/
/*end options menu*/
if ($pmVersion != "") {
$arrayImportFileExtension = (version_compare($pmVersion . "", "3", ">="))? $arrayImportFileExtension : array("pm");
$arrayMenuNewOption = (version_compare($pmVersion . "", "3", ">="))? array("bpmn" => true) : array("pm" => true);
@@ -52,4 +136,8 @@ $oHeadPublisher->assign( 'pageSize', $conf->getEnvSetting( 'casesListRowNumber'
$oHeadPublisher->assign("arrayImportFileExtension", $arrayImportFileExtension);
$oHeadPublisher->assign("arrayMenuNewOption", $arrayMenuNewOption);
$oHeadPublisher->assign("arrayMenuNew", $arrayMenuNew);
$oHeadPublisher->assign("contexMenu", $contexMenuRightClick);
$oHeadPublisher->assign("jsFromPlugin", $jsFromPlugin);
G::RenderPage( 'publish', 'extJs' );

View File

@@ -178,36 +178,17 @@ Ext.onReady(function(){
items:[_('ID_PAGE_SIZE')+':',comboPageSize]
}) */
var mnuNewBpmnProject = {
text: _('ID_NEW_BPMN_PROJECT'),
iconCls: "silk-add",
icon: "",
handler: function ()
{
newProcess({type:"bpmnProject"});
for(var k=0;k<arrayMenuNew.length;k++) {
var handlerMenu = arrayMenuNew[k].handler;
arrayMenuNew[k].handler = new Function(handlerMenu)
}
};
var mnuNewProject = {
text: _('ID_NEW_PROJECT'),
iconCls: "silk-add",
icon: "",
handler: function ()
{
newProcess({type: "classicProject"});
}
};
var arrayMenuNew = [];
if (typeof(arrayMenuNewOption["bpmn"]) != "undefined") {
arrayMenuNew.push(mnuNewBpmnProject);
typeMnuNew = "bpmnProject";
for(var j=0;j<contexMenu.length;j++) {
var handlerMenu = contexMenu[j].handler;
contexMenu[j].handler = new Function(handlerMenu)
}
if (typeof(arrayMenuNewOption["pm"]) != "undefined") {
arrayMenuNew.push(mnuNewProject);
typeMnuNew = "classicProject";
if(jsFromPlugin) {
injectScriptElement(jsFromPlugin);
}
if(typeof(arrayMenuNewOption["bpmn"]) != "undefined" && typeof(arrayMenuNewOption["pm"]) != "undefined"){
@@ -460,41 +441,7 @@ Ext.onReady(function(){
var messageContextMenu = new Ext.menu.Menu({
id: 'messageContextMenu',
items: [{
text: _('ID_EDIT'),
iconCls: 'button_menu_ext ss_sprite ss_pencil',
handler: editProcess
}, {
id: 'activator2',
text: '',
icon: '',
handler: activeDeactive
}, {
id: 'debug',
text: '',
handler: enableDisableDebug
}, {
text: _('ID_DELETE'),
iconCls: "button_menu_ext ss_sprite ss_cross",
handler: deleteProcess
}, {
text: _("ID_EXPORT"),
icon: "/images/export.png",
handler: function () {
exportProcess();
}
},
{
id: "mnuGenerateBpmn",
text: _("ID_GENERATE_BPMN_PROJECT"),
iconCls: "button_menu_ext ss_sprite ss_page_white_go",
hidden: true,
handler: function ()
{
generateBpmn();
}
}
]
items: contexMenu
});
var viewport = new Ext.Viewport({
@@ -512,7 +459,10 @@ function newProcess(params)
params = typeof params == 'undefined' ? {type:'classicProject'} : params;
// TODO this variable have hardcoded labels, it must be changed on the future
var formTitle = params.type == "classicProject" ? _('ID_NEW_PROJECT') : _('ID_NEW_BPMN_PROJECT')
var formTitle = params.title;
if(typeof formTitle === "undefined") {
formTitle = params.type == "classicProject" ? _('ID_NEW_PROJECT') : _('ID_NEW_BPMN_PROJECT');
}
// window.location = 'processes_New';
var ProcessCategories = new Ext.form.ComboBox({
@@ -647,6 +597,10 @@ function doSearch(){
editProcess = function(typeParam)
{
if(jsFromPlugin) {
pluginFunctions.onRowdblclick();
}
var rowSelected = processesGrid.getSelectionModel().getSelected();
if (!rowSelected) {
Ext.Msg.show({
@@ -1538,3 +1492,11 @@ function openWindowIfIE(pathDesigner) {
}
location.href = pathDesigner;
}
function injectScriptElement(url, onLoad, onError, scope) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
return script;
}