diff --git a/gulliver/system/class.controller.php b/gulliver/system/class.controller.php
index 2d7ee8364..8443fe973 100755
--- a/gulliver/system/class.controller.php
+++ b/gulliver/system/class.controller.php
@@ -1,13 +1,17 @@
* @package gulliver.system
* @access private
*/
-class Controller
+class Controller
{
-
+ /**
+ * @var boolean debug switch for general purpose
+ */
+ public $debug = null;
/**
* @var array - private array to store proxy data
*/
@@ -18,16 +22,15 @@ class Controller
*/
private $__request__;
- protected $headPublisher;
+ /**
+ * @var object - headPublisher object to handle the output
+ */
+ private $headPublisher = null;
- public $ExtVar = Array();
-
- public $controllerClass = '';
-
- public function __construct()
- {
- $this->headPublisher = headPublisher::getSingleton();
- }
+ /**
+ * @var string - response type var. possibles values: json|plain
+ */
+ private $responseType = '';
/**
* Magic setter method
@@ -37,7 +40,6 @@ class Controller
*/
public function __set($name, $value)
{
- //echo "Setting '$name' to '$value'\n";
$this->__data__[$name] = $value;
}
@@ -49,7 +51,6 @@ class Controller
*/
public function __get($name)
{
- //echo "Getting '$name'\n";
if (array_key_exists($name, $this->__data__)) {
return $this->__data__[$name];
}
@@ -65,55 +66,78 @@ class Controller
/**
* Magic isset method
- *
* @param string $name
*/
public function __isset($name)
{
- //echo "Is '$name' set?\n";
return isset($this->__data__[$name]);
}
/**
* Magic unset method
- *
* @param string $name
*/
public function __unset($name)
{
- //echo "Unsetting '$name'\n";
unset($this->__data__[$name]);
}
+
+ /**
+ * Set Response type method
+ * @param string $type contains : json|plain
+ */
+ public function setResponseType($type)
+ {
+ $this->responseType = $type;
+ }
/**
* call to execute a internal proxy method and handle its exceptions
- *
* @param string $name
*/
public function call($name)
{
- //echo __CLASS__;
try {
-
- $this->$name($this->__request__);
-
+ $result = $this->$name($this->__request__);
+ if ($this->responseType == 'json') {
+ print G::json_encode($result);
+ }
} catch (Exception $e) {
- $template = new TemplatePower(PATH_TEMPLATE . 'controller.exception.tpl');
- $template->prepare();
- $template->assign('controller', get_called_class());
- $template->assign('message', $e->getMessage());
- $template->assign('file', $e->getFile());
- $template->assign('line', $e->getLine());
- $template->assign('trace', $e->getTraceAsString());
+ if ($this->responseType != 'json') {
+ $result->exception->class = get_class($e);
+ $result->exception->code = $e->getCode();
- echo $template->getOutputContent();
+ $template = new TemplatePower(PATH_TEMPLATE . 'controller.exception.tpl');
+ $template->prepare();
+ $template->assign('controller', get_called_class());
+ $template->assign('message', $e->getMessage());
+ $template->assign('file', $e->getFile());
+ $template->assign('line', $e->getLine());
+ $template->assign('trace', $e->getTraceAsString());
+
+ echo $template->getOutputContent();
+
+ } else {
+ $result->success = false;
+ $result->msg = $e->getMessage();
+ switch(get_class($e)) {
+ case 'Exception': $error = "SYSTEM ERROR"; break;
+ case 'PMException': $error = "PROCESSMAKER ERROR"; break;
+ case 'PropelException': $error = "DATABASE ERROR"; break;
+ case 'UserException': $error = "USER ERROR"; break;
+ }
+ $result->error = $error;
+
+ $result->exception->class = get_class($e);
+ $result->exception->code = $e->getCode();
+ print G::json_encode($result);
+ }
}
}
/**
* Set the http request data
- *
* @param array $data
*/
public function setHttpRequestData($data)
@@ -124,20 +148,93 @@ class Controller
} else
$this->__request__ = $data;
}
+
+ /**
+ * Get debug var. method
+ * @param boolan $val boolean value for debug var.
+ */
+ public function setDebug($val)
+ {
+ $this->debug = $val;
+ }
+
+ /**
+ * Get debug var. method
+ */
+ public function getDebug()
+ {
+ if ($this->debug === null) {
+ $this->debug = defined('DEBUG') && DEBUG ? true : false;
+ }
+
+ return $this->debug;
+ }
+
+ /*** HeadPublisher Functions Binding ***/
+
+ /**
+ * Include a particular extjs library or extension to the main output
+ * @param string $srcFile path of a extjs library or extension
+ * @param boolean $debug debug flag to indicate if the js output will be minifield or not
+ * $debug: true -> the js content will be not minified (readable)
+ * false -> the js content will be minified
+ */
+ public function includeExtJSLib($srcFile, $debug=false)
+ {
+ $this->getHeadPublisher()->usingExtJs($srcFile, ($debug ? $debug : $this->getDebug()));
+ }
+
+ /**
+ * Include a javascript file that is using extjs framework to the main output
+ * @param string $srcFile path of javascrit file to include
+ * @param boolean $debug debug flag to indicate if the js output will be minifield or not
+ * $debug: true -> the js content will be not minified (readable)
+ * false -> the js content will be minified
+ */
public function includeExtJS($srcFile, $debug=false)
{
- $this->headPublisher->addExtJsScript($srcFile,true );
-
+ $this->getHeadPublisher()->addExtJsScript($srcFile, ($debug ? $debug : $this->getDebug()));
}
+ /**
+ * Include a Html file to the main output
+ * @param string $file path of html file to include to the main output
+ */
public function setView($file)
{
- $this->headPublisher->addContent($file,true );
+ $this->getHeadPublisher()->addContent($file);
}
+ /**
+ * Set variables to be accesible by javascripts
+ * @param string $name contains var. name
+ * @param string $value conatins var. value
+ */
public function setJSVar($name, $value)
{
- $this->headPublisher->assign($name, $value);
+ $this->getHeadPublisher()->assign($name, $value);
+ }
+
+ /**
+ * Set variables to be accesible by the extjs layout template
+ * @param string $name contains var. name
+ * @param string $value conatins var. value
+ */
+ public function setVar($name, $value)
+ {
+ $this->getHeadPublisher()->sssignVar($name, $value);
+ }
+
+ /**
+ * method to get the local getHeadPublisher object
+ */
+ public function getHeadPublisher()
+ {
+ if (!is_object($this->headPublisher)) {
+ $this->headPublisher = headPublisher::getSingleton();
+ }
+
+ return $this->headPublisher;
}
}
diff --git a/gulliver/system/class.httpProxyController.php b/gulliver/system/class.httpProxyController.php
index 301fbba4d..3c3783852 100755
--- a/gulliver/system/class.httpProxyController.php
+++ b/gulliver/system/class.httpProxyController.php
@@ -17,6 +17,8 @@ class HttpProxyController {
* @var object - private object to store the http request data
*/
private $__request__;
+
+ public $jsonResponse = true;
private $sendResponse = true;
/**
@@ -81,6 +83,11 @@ class HttpProxyController {
{
try {
$result = $this->$name($this->__request__);
+
+ if (!$this->jsonResponse) {
+ return null;
+ }
+
if( ! $result )
$result = $this->__data__;
@@ -119,6 +126,11 @@ class HttpProxyController {
$this->__request__ = $data;
}
+ public function setJsonResponse($bool)
+ {
+ $this->jsonResponse = $bool;
+ }
+
/**
* Send response to client
*
diff --git a/workflow/engine/controllers/dashboard.php b/workflow/engine/controllers/dashboard.php
new file mode 100644
index 000000000..5af24a2eb
--- /dev/null
+++ b/workflow/engine/controllers/dashboard.php
@@ -0,0 +1,23 @@
+PRO_UID (opional)
+ */
+ public function index($httpData)
+ {
+ $this->includeExtJS('dashboard/index');
+ $this->includeExtJSLib('ux/portal');
+ //$this->setView('dashboard/index');
+
+ //render content
+ G::RenderPage('publish', 'extJs');
+ }
+}
\ No newline at end of file
diff --git a/workflow/engine/menus/processmaker.php b/workflow/engine/menus/processmaker.php
index 2c2a52e33..2f5648f81 100755
--- a/workflow/engine/menus/processmaker.php
+++ b/workflow/engine/menus/processmaker.php
@@ -45,6 +45,10 @@ if ($RBAC->userCanAccess('PM_FACTORY') == 1 ) {
$G_TMP_MENU->AddIdRawOption('PROCESSES', 'processes/main', G::LoadTranslation('ID_DESIGNER'));
}
+// DASHBOARD MODULE
+if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
+ $G_TMP_MENU->AddIdRawOption('DASHBOARD', 'dashboard/main', G::LoadTranslation('ID_DASHBOARD'));
+}
/*if ($RBAC->userCanAccess('PM_REPORTS') == 1 ) {
$G_TMP_MENU->AddIdRawOption('REPORTS', 'reports/reportsList');
diff --git a/workflow/engine/methods/dashboard/main.php b/workflow/engine/methods/dashboard/main.php
new file mode 100644
index 000000000..209c0b172
--- /dev/null
+++ b/workflow/engine/methods/dashboard/main.php
@@ -0,0 +1,33 @@
+.
+ *
+ * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
+ * Coral Gables, FL, 33134, USA, or email info@colosa.com.
+ *
+ */
+
+$RBAC->requirePermissions('PM_DASHBOARD');
+
+$G_MAIN_MENU = 'processmaker';
+$G_ID_MENU_SELECTED = 'DASHBOARD';
+
+$G_PUBLISH = new Publisher;
+$G_PUBLISH->AddContent('view', 'dashboard/load');
+G::RenderPage('publish');
diff --git a/workflow/engine/templates/dashboard/index.js b/workflow/engine/templates/dashboard/index.js
new file mode 100644
index 000000000..49ab68904
--- /dev/null
+++ b/workflow/engine/templates/dashboard/index.js
@@ -0,0 +1,183 @@
+Ext.onReady(function(){
+
+ Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
+
+ // create some portlet tools using built in Ext tool ids
+ var tools = [{
+ id:'gear',
+ handler: function(){
+ Ext.Msg.alert('Message', 'The Settings tool was clicked.');
+ }
+ },{
+ id:'close',
+ handler: function(e, target, panel){
+ panel.ownerCt.remove(panel, true);
+ }
+ }];
+
+ var tbDashboard = new Ext.Toolbar({
+ height: 30,
+ items: [
+ {
+ xtype: 'tbbutton',
+ text : 'three columns',
+ handler : function(a) {
+ var vp = Ext.getCmp('viewportDashboard');
+ var pd = Ext.getCmp('portalDashboard');
+ pd.items.items[0].columnWidth = 0.33;
+ pd.items.items[1].columnWidth = 0.33;
+ pd.items.items[2].columnWidth = 0.33;
+ pd.doLayout();
+ }
+ },
+ {
+ xtype: 'tbbutton',
+ text : 'two columns',
+ handler : function(a) {
+ var vp = Ext.getCmp('viewportDashboard');
+ var pd = Ext.getCmp('portalDashboard');
+ pd.items.items[0].columnWidth = 0.49;
+ pd.items.items[1].columnWidth = 0.49;
+ while ( pd.items.items[2].items.items[0] ) {
+ pd.items.items[0].add( pd.items.items[2].items.items[0] );
+ }
+ pd.items.items[2].columnWidth = 0.01;
+ pd.doLayout();
+ }
+ },
+ {
+ xtype: 'tbbutton',
+ text : 'blog',
+ handler : function(a) {
+ var vp = Ext.getCmp('viewportDashboard');
+ var pd = Ext.getCmp('portalDashboard');
+ pd.items.items[0].columnWidth = 0.40;
+ pd.items.items[1].columnWidth = 0.40;
+ pd.items.items[2].columnWidth = 0.20;
+ pd.doLayout();
+ //vp.doLayout();
+ }
+ },
+ {
+ xtype: 'tbbutton',
+ text : 'new gauge',
+ handler : function(a) {
+ var np = new Ext.ux.Portlet ( {
+ //title: 'Panel nuevo',
+ //tools: tools,
+ html: 'hello world',
+ listeners: {
+ 'render': function(p){
+ p.html = 'hello ' + p.getWidth();
+ },
+ 'move' : function(p){
+ Ext.Msg.alert('Portlet ', 'move ' + p.getWidth() );
+ p.html = 'show ' + p.getWidth();
+ },
+ 'resize' : function(p,w,h){
+ var randomnumber=Math.floor(Math.random()*1000000)
+ var img = new Ext.XTemplate("").apply({
+ page: 'http://javaserver.colosa.net/ext/examples/portal/gauge.php', width:w, random: randomnumber })
+
+ p.update(img );
+ }
+ }
+ });
+
+ var vp = Ext.getCmp('viewportDashboard');
+ var pd = Ext.getCmp('portalDashboard');
+ pd.items.items[0].add( np );
+ pd.doLayout();
+ //vp.doLayout();
+ }
+ },
+ {
+ xtype: 'tbbutton',
+ text : 'new trend graph',
+ handler : function(a) {
+ var np = new Ext.ux.Portlet ( {
+ //title: 'Panel nuevo',
+ tools: tools,
+ html: 'hello world',
+ listeners: {
+ 'render': function(p){
+ p.html = 'hello ' + p.getWidth();
+ },
+ 'move' : function(p){
+ Ext.Msg.alert('Portlet ', 'move ' + p.getWidth() );
+ p.html = 'show ' + p.getWidth();
+ },
+ 'resize' : function(p,w,h){
+ var randomnumber=Math.floor(Math.random()*1000000)
+ var img = new Ext.XTemplate("
").apply({
+ page: 'http://javaserver.colosa.net/ext/examples/portal/history.php', width:w, random: randomnumber })
+
+ p.update(img );
+ }
+ }
+ });
+
+ var vp = Ext.getCmp('viewportDashboard');
+ var pd = Ext.getCmp('portalDashboard');
+ pd.items.items[0].add( np );
+ pd.doLayout();
+ //vp.doLayout();
+ }
+ }
+ ]
+ });
+
+ var viewport = new Ext.Viewport({
+ layout:'fit',
+ name : 'viewportDashboard',
+ id : 'viewportDashboard',
+ items:[{
+ xtype:'portal',
+ region:'center',
+ margins:'35 5 5 0',
+ tbar: tbDashboard,
+ name : 'portalDashboard',
+ id : 'portalDashboard',
+ items:[{
+ columnWidth:.33,
+ style:'padding:10px 0 10px 10px',
+ items:[{
+ title: 'Grid in a Portlet',
+ layout:'fit',
+ tools: tools,
+ html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
+ //items: new SampleGrid([0, 2, 3])
+ }]
+ },{
+ columnWidth:.33,
+ style:'padding:10px 0 10px 10px',
+ items:[{
+ title: 'Panel 2',
+ tools: tools,
+ html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
+ }]
+ },{
+ columnWidth:.33,
+ style:'padding:10px',
+ items:[{
+ title: 'Panel 3',
+ tools: tools,
+ html: 'Learn Use the included files to view samples and our API documentation. For advanced, hands-on support, please see our premium support subscriptions. Larger organizations can use our enterprise training and services.'
+ }]
+ }]
+
+ /*
+ * Uncomment this block to test handling of the drop event. You could use this
+ * to save portlet position state for example. The event arg e is the custom
+ * event defined in Ext.ux.Portal.DropZone.
+ */
+// ,listeners: {
+// 'drop': function(e){
+// Ext.Msg.alert('Portlet Dropped', e.panel.title + '
Column: ' +
+// e.columnIndex + '
Position: ' + e.position);
+// }
+// }
+ }]
+ });
+});
+
diff --git a/workflow/engine/templates/dashboard/load.php b/workflow/engine/templates/dashboard/load.php
new file mode 100644
index 000000000..248cd7ed7
--- /dev/null
+++ b/workflow/engine/templates/dashboard/load.php
@@ -0,0 +1,39 @@
+
+
+