From 27af603aab04158f98825bfd8ba357b55c6ce558 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 03:52:51 -0800 Subject: [PATCH 01/40] Added folder for graph images --- modules/formulize/images/graphs/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 modules/formulize/images/graphs/index.html diff --git a/modules/formulize/images/graphs/index.html b/modules/formulize/images/graphs/index.html new file mode 100644 index 000000000..990cbd603 --- /dev/null +++ b/modules/formulize/images/graphs/index.html @@ -0,0 +1 @@ + \ No newline at end of file From ee0c153d2aa4f892cab9e72aad7b731612c4bae9 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 04:47:00 -0800 Subject: [PATCH 02/40] New table for graph screen --- modules/formulize/admin/formindex.php | 18 ++++++++++++++++++ modules/formulize/sql/mysql.sql | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index 9af1df877..5d7ecf879 100755 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -281,6 +281,24 @@ function patch40() { INDEX i_del_id (del_log_id) ) ENGINE=MyISAM;"; } + + if(!in_array($xoopsDB->prefix("formulize_screen_graph"), $existingTables)) { + $sql[] = "CREATE TABLE `".$xoopsDB->prefix("formulize_screen_graph")."` ( + `formid` int(11) NOT NULL auto_increment, + `sid` int(11) NOT NULL default 0, + `width` int(11) NOT NULL default 800, + `height` int(11) NOT NULL default 600, + `orientation` varchar(255) NOT NULL default 'horizontal', + `bgr` int(8) NOT NULL default 141, + `bgg` int(8) NOT NULL default 189, + `bgb` int(8) NOT NULL default 225, + `barr` int(8) NOT NULL default 143, + `barg` int(8) NOT NULL default 190, + `barb` int(8) NOT NULL default 88, + PRIMARY KEY (`formid`), + INDEX i_sid (`sid`) +) ENGINE=MyISAM;"; + } // if this is a standalone installation, then we want to make sure the session id field in the DB is large enough to store whatever session id we might be working with if(file_exists(XOOPS_ROOT_PATH."/integration_api.php")) { diff --git a/modules/formulize/sql/mysql.sql b/modules/formulize/sql/mysql.sql index b05b8df5d..a577d7869 100755 --- a/modules/formulize/sql/mysql.sql +++ b/modules/formulize/sql/mysql.sql @@ -372,3 +372,18 @@ CREATE TABLE formulize_deletion_logs ( INDEX i_del_id (del_log_id) ) ENGINE=MyISAM; +CREATE TABLE `formulize_screen_graph` ( + `formid` int(11) NOT NULL auto_increment, + `sid` int(11) NOT NULL default 0, + `width` int(11) NOT NULL default 500, + `height` int(11) NOT NULL default 300, + `orientation` varchar(255) NOT NULL default 'horizontal', + `bgr` int(8) NOT NULL default 141, + `bgg` int(8) NOT NULL default 189, + `bgb` int(8) NOT NULL default 225, + `barr` int(8) NOT NULL default 143, + `barg` int(8) NOT NULL default 190, + `barb` int(8) NOT NULL default 88, + PRIMARY KEY (`formid`), + INDEX i_sid (`sid`) +) ENGINE=MyISAM; From 30b86a75525a9508a3e5e91b2710a29d2964750a Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 04:53:00 -0800 Subject: [PATCH 03/40] Graph screen php class --- modules/formulize/class/graphScreen.php | 135 ++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 modules/formulize/class/graphScreen.php diff --git a/modules/formulize/class/graphScreen.php b/modules/formulize/class/graphScreen.php new file mode 100644 index 000000000..f72be42a6 --- /dev/null +++ b/modules/formulize/class/graphScreen.php @@ -0,0 +1,135 @@ +formulizeScreen(); + $this->initvar("width", XOBJ_DTYPE_INT); + $this->initvar("height", XOBJ_DTYPE_INT); + $this->initvar("orientation", XOBJ_DTYPE_TXTBOX, NULL, false, 255); + $this->initvar("bgr", XOBJ_DTYPE_INT); + $this->initvar("bgg", XOBJ_DTYPE_INT); + $this->initvar("bgb", XOBJ_DTYPE_INT); + $this->initvar("barr", XOBJ_DTYPE_INT); + $this->initvar("barg", XOBJ_DTYPE_INT); + $this->initvar("barb", XOBJ_DTYPE_INT); + } +} + +class formulizeGraphScreenHandler extends formulizeScreenHandler { + var $db; + function formulizeGraphScreenHandler(&$db) { + $this->db =& $db; + } + function &getInstance(&$db) { + static $instance; + if (!isset($instance)) { + $instance = new formulizeGraphScreenHandler($db); + } + return $instance; + } + function &create() { + return new formulizeGraphScreen(); + } + + + function insert($screen) { + // sid is being used as a flag to update or not + $update = ($screen->getVar('sid') == 0) ? false : true; + // insert or update and get the actual sid + if(!$sid = parent::insert($screen)) { // write the basic info to the db, handle cleaning vars and all that jazz. Object passed by reference, so updates will have affected it in the other method. + return false; + } + $screen->assignVar('sid', $sid); + // standard flags used by xoopsobject class + $screen->setVar('dohtml', 0); + $screen->setVar('doxcode', 0); + $screen->setVar('dosmiley', 0); + $screen->setVar('doimage', 0); + $screen->setVar('dobr', 0); + // note: conditions is not written to the DB yet, since we're not gathering that info from the UI + if (!$update) { + $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb')); + } else { + $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $screen->getVar('sid')); + } + $result = $this->db->query($sql); + if (!$result) { + print "Error: could not save the screen properly: ".mysql_error()." for query: $sql"; + return false; + } + return $sid; + } + + // THIS METHOD MIGHT BE MOVED UP A LEVEL TO THE PARENT CLASS + function get($sid) { + $sid = intval($sid); + if ($sid > 0) { + $sql = 'SELECT * FROM '.$this->db->prefix('formulize_screen').' AS t1, '. $this->db->prefix('formulize_screen_graph').' AS t2 WHERE t1.sid='.$sid.' AND t1.sid=t2.sid'; + if (!$result = $this->db->query($sql)) { + return false; + } + $numrows = $this->db->getRowsNum($result); + if ($numrows == 1) { + $screen = new formulizeGraphScreen(); + $screen->assignVars($this->db->fetchArray($result)); + return $screen; + } + } + return false; + + } + + // THIS METHOD HANDLES ALL THE LOGIC ABOUT HOW TO ACTUALLY DISPLAY THIS TYPE OF SCREEN + // $screen is a screen object + function render($screen, $entry, $settings = "") { // $settings is used internally to pass list of entries settings back and forth to editing screens + /* + if(!is_array($settings)) { + $settings = ""; + } + $formframe = $screen->getVar('frid') ? $screen->getVar('frid') : $screen->getVar('fid'); + $mainform = $screen->getVar('frid') ? $screen->getVar('fid') : ""; + $donedest = $screen->getVar("donedest"); + $savebuttontext = $screen->getVar("savebuttontext"); + $savebuttontext = $savebuttontext ? $savebuttontext : _formulize_SAVE; + $alldonebuttontext = $screen->getVar("alldonebuttontext"); + $alldonebuttontext = $alldonebuttontext ? $alldonebuttontext : "{NOBUTTON}"; + $displayheading = $screen->getVar('displayheading'); + $displayheading = $displayheading ? "" : "all"; // if displayheading is off, then need to pass the "all" keyword to supress all the headers + $reloadblank = $screen->getVar('reloadblank'); + // figure out the form's properties... + // if it's more than one entry per user, and we have requested reload blank, then override multi is 0, otherwise 1 + // if it's one entry per user, and we have requested reload blank, then override multi is 1, otherwise 0 + $form_handler = xoops_getmodulehandler('forms', 'formulize'); + $formObject = $form_handler->get($screen->getVar('fid')); + if($formObject->getVar('single')=="off" AND $reloadblank) { + $overrideMulti = 0; + } elseif($formObject->getVar('single')=="off" AND !$reloadblank) { + $overrideMulti = 1; + } elseif(($formObject->getVar('single')=="group" OR $formObject->getVar('single')=="user") AND $reloadblank) { + $overrideMulti = 1; + } elseif(($formObject->getVar('single')=="group" OR $formObject->getVar('single')=="user") AND !$reloadblank) { + $overrideMulti = 0; + } else { + $overrideMulti = 0; + } + include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplay.php"; + displayForm($formframe, $entry, $mainform, $donedest, array(0=>$alldonebuttontext, 1=>$savebuttontext), + $settings, $displayheading, "", $overrideMulti, "", 0, 0, 0, $screen); + */ + $options = [ + "width" => $screen->getVar('width'), + "height" => $screen->getVar('height'), + ]; + include_once XOOPS_ROOT_PATH."/modules/formulize/include/graphdisplay.php"; + displayGraph('Bar', $screen->getVar('fid'), $screen->getVar('frid'), 2, 2, 'sum', $options); + } +} +?> From 51ce522b0a5e8998b51b399573b82127e49f25de Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 04:57:41 -0800 Subject: [PATCH 04/40] fixed file requirement --- modules/formulize/include/graphdisplay.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index 443f6a331..96f2a8450 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -35,6 +35,8 @@ include_once XOOPS_ROOT_PATH . "/modules/formulize/libraries/pChart/class/pDraw.class.php"; include_once XOOPS_ROOT_PATH . "/modules/formulize/libraries/pChart/class/pImage.class.php"; +include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php"; + /** * IMPORTANT: Implemented User Cases: * 1. bar graph "count": From f6a889f58f8770fa793607b9b77931597dfb668b Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 04:59:12 -0800 Subject: [PATCH 05/40] fixed table patching for gs table --- modules/formulize/admin/formindex.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index 5d7ecf879..393925b7b 100755 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -111,8 +111,8 @@ function patch40() { * * ====================================== */ - $checkThisTable = 'formulize_deletion_logs'; - $checkThisField = 'context'; + $checkThisTable = 'formulize_screen_graph'; + $checkThisField = 'barb'; $checkThisProperty = false; $checkPropertyForValue = false; From 0261fd95e64ed59135c5734d1960ce06b51162dd Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 05:01:23 -0800 Subject: [PATCH 06/40] fixed a missing tag --- modules/formulize/templates/admin/screen_form_options.html | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/formulize/templates/admin/screen_form_options.html b/modules/formulize/templates/admin/screen_form_options.html index e14ebaf9e..0da23834a 100644 --- a/modules/formulize/templates/admin/screen_form_options.html +++ b/modules/formulize/templates/admin/screen_form_options.html @@ -47,6 +47,7 @@
You can leave this blank, and if you do then the default All Done action will happen. Depending on the circumstance, the default action is either the form reloading, or the user returning to the previous page. If you do specify an All Done location, and you are sending users to a location on this site, then you don't have to type the root part of the site's URL. Just start the destination with a slash, ie: /modules/formulize/index.php?sid=12
+
Form Elements
From 8afce00fd43fc6ac72e7f9a462e76aa57e41cbcb Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 05:11:01 -0800 Subject: [PATCH 07/40] New graph options template and save --- .../admin/save/screen_graph_options_save.php | 45 ++++++++++++ .../templates/admin/screen_graph_options.html | 70 +++++++++++++++++++ modules/formulize/xoops_version.php | 3 + 3 files changed, 118 insertions(+) create mode 100644 modules/formulize/admin/save/screen_graph_options_save.php create mode 100644 modules/formulize/templates/admin/screen_graph_options.html diff --git a/modules/formulize/admin/save/screen_graph_options_save.php b/modules/formulize/admin/save/screen_graph_options_save.php new file mode 100644 index 000000000..0abfbb2f2 --- /dev/null +++ b/modules/formulize/admin/save/screen_graph_options_save.php @@ -0,0 +1,45 @@ +get($sid); + +// CHECK IF THE FORM IS LOCKED DOWN AND SCOOT IF SO +$form_handler = xoops_getmodulehandler('forms', 'formulize'); +$formObject = $form_handler->get($screen->getVar('fid')); +if($formObject->getVar('lockedform')) { + return; +} +// check if the user has permission to edit the form +if(!$gperm_handler->checkRight("edit_form", $screen->getVar('fid'), $groups, $mid)) { + return; +} + + +$screen->setVar('width',$screens['width']); +$screen->setVar('height',$screens['height']); +$screen->setVar('orientation',$screens['orientation']); +$screen->setVar('bgr',$screens['bgr']); +$screen->setVar('bgg',$screens['bgg']); +$screen->setVar('bgb',$screens['bgb']); +$screen->setVar('barr',$screens['barr']); +$screen->setVar('barg',$screens['barg']); +$screen->setVar('barb',$screens['barb']); + + +if(!$screen_handler->insert($screen)) { + print "Error: could not save the screen properly: ".mysql_error(); +} +?> diff --git a/modules/formulize/templates/admin/screen_graph_options.html b/modules/formulize/templates/admin/screen_graph_options.html new file mode 100644 index 000000000..1ae6164f0 --- /dev/null +++ b/modules/formulize/templates/admin/screen_graph_options.html @@ -0,0 +1,70 @@ +<{* form elements must be named with their object name hyphen field name *}> +<{* no other elements should have hyphens, since that tells the saving system that this is a property of an object to update *}> +<{* securitytoken should be part of the form *}> +<{* formulize_admin_handler and formulize_admin_key are required, to tell what the name of the save handling file is, and what the key is that we're inserting/updating on *}> + +
+<{$securitytoken}> + + + + +
+
+ Dimension +
+ + +
+
+ + +
+
+
+ Orientation +
+ + +
+
+
+ Background Color +
+ + +
+
+ + +
+
+ + +
+
+
+ Bar Color +
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ + \ No newline at end of file diff --git a/modules/formulize/xoops_version.php b/modules/formulize/xoops_version.php index 931725213..5cbbd011f 100644 --- a/modules/formulize/xoops_version.php +++ b/modules/formulize/xoops_version.php @@ -295,6 +295,9 @@ $modversion['templates'][] = array( 'file' => 'admin/export_template.html', 'description' => ''); +$modversion['templates'][] = array( + 'file' => 'admin/screen_graph_options.html', + 'description' => ''); // Module Configs // $xoopsModuleConfig['t_width'] From da6915b415d80387654364ee6064d50e65c12687 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 05:12:14 -0800 Subject: [PATCH 08/40] more option saving changes --- modules/formulize/admin/form.php | 8 +++++++ .../admin/save/screen_settings_save.php | 15 ++++++++++++- modules/formulize/admin/screen.php | 21 +++++++++++++++++++ modules/formulize/language/english/admin.php | 4 +++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/modules/formulize/admin/form.php b/modules/formulize/admin/form.php index 077c8e510..f84480253 100644 --- a/modules/formulize/admin/form.php +++ b/modules/formulize/admin/form.php @@ -307,6 +307,7 @@ $common['aid'] = $aid; $common['defaultform'] = $defaultform; $common['defaultlist'] = $defaultlist; +// no default graph $common['form_object'] = $formObject; $permissions = array(); @@ -332,6 +333,13 @@ $screens['listOfEntries'][$i]['title'] = $screen->getVar('title'); $i++; } +$graphsScreens = $screen_handler->getObjects(new Criteria('type','graph'),$fid); +$i = 1; +foreach($graphsScreens as $screen) { + $screens['graphs'][$i]['sid'] = $screen->getVar('sid'); + $screens['graphs'][$i]['title'] = $screen->getVar('title'); + $i++; +} $settings = array(); $settings['singleentry'] = $singleentry; diff --git a/modules/formulize/admin/save/screen_settings_save.php b/modules/formulize/admin/save/screen_settings_save.php index 11faa36e4..31905a646 100644 --- a/modules/formulize/admin/save/screen_settings_save.php +++ b/modules/formulize/admin/save/screen_settings_save.php @@ -60,6 +60,8 @@ $screen_handler = xoops_getmodulehandler('listOfEntriesScreen', 'formulize'); } else if($screens['type'] == 'form') { $screen_handler = xoops_getmodulehandler('formScreen', 'formulize'); +} else if($screens['type'] == 'graph') { + $screen_handler = xoops_getmodulehandler('graphScreen', 'formulize'); } @@ -115,7 +117,18 @@ $screen->setVar('reloadblank', 0); $screen->setVar('savebuttontext', _formulize_SAVE); $screen->setVar('alldonebuttontext', _formulize_DONE); - } + } else if($screens['type'] == 'graph') { + // Defaults + $screen->setVar('width', 500); + $screen->setVar('height', 300); + $screen->setVar('orientation', "horizontal"); + $screen->setVar('bgr', 141); + $screen->setVar('bgg', 189); + $screen->setVar('bgb', 225); + $screen->setVar('barr', 143); + $screen->setVar('barg', 190); + $screen->setVar('barb', 88); + } } else { diff --git a/modules/formulize/admin/screen.php b/modules/formulize/admin/screen.php index c74ab66c3..2ea531661 100644 --- a/modules/formulize/admin/screen.php +++ b/modules/formulize/admin/screen.php @@ -62,6 +62,8 @@ $screen_handler = xoops_getmodulehandler('formScreen', 'formulize'); } else if($settings['type'] == 'multiPage') { $screen_handler = xoops_getmodulehandler('multiPageScreen', 'formulize'); + } else if($settings['type'] == 'graph') { + $screen_handler = xoops_getmodulehandler('graphScreen', 'formulize'); } $screen = $screen_handler->get($screen_id); @@ -390,6 +392,19 @@ function multiPageScreen_addToOptionsList($form_id, $options) { $options['element_list'] = $element_list; } +if($screen_id != "new" && $settings['type'] == 'graph') { + $graph_options = array(); + $graph_options['width'] = $screen->getVar('width'); + $graph_options['height'] = $screen->getVar('height'); + $graph_options['orientation'] = $screen->getVar('orientation'); + $graph_options['bgr'] = $screen->getVar('bgr'); + $graph_options['bgg'] = $screen->getVar('bgg'); + $graph_options['bgb'] = $screen->getVar('bgb'); + $graph_options['barr'] = $screen->getVar('barr'); + $graph_options['barg'] = $screen->getVar('barg'); + $graph_options['barb'] = $screen->getVar('barb'); +} + // common values should be assigned to all tabs $common['name'] = $screenName; $common['title'] = $screenName; // oops, we've got two copies of this data floating around...standardize sometime @@ -456,6 +471,12 @@ function multiPageScreen_addToOptionsList($form_id, $options) { $adminPage['tabs'][6]['content'] = $templates + $common; } +if($screen_id != "new" && $settings['type'] == 'graph') { + $adminPage['tabs'][2]['name'] = _AM_GRAPH_SCREEN_OPTIONS; + $adminPage['tabs'][2]['template'] = "db:admin/screen_graph_options.html"; + $adminPage['tabs'][2]['content'] = $graph_options + $common; +} + $adminPage['pagetitle'] = _AM_FORM_SCREEN.$screenName; $adminPage['needsave'] = true; $adminPage['show_user_view'] = array("View Screen", XOOPS_URL."/modules/formulize/index.php?sid=$screen_id"); diff --git a/modules/formulize/language/english/admin.php b/modules/formulize/language/english/admin.php index a08c4bbcf..3daef3d9d 100644 --- a/modules/formulize/language/english/admin.php +++ b/modules/formulize/language/english/admin.php @@ -167,6 +167,7 @@ define("_AM_SCREEN_CREATE"," Create a new Screen"); define("_AM_SCREEN_FORMSCREENS","Form Screens"); define("_AM_SCREEN_LISTSCREENS","List Screens"); +define("_AM_SCREEN_GRAPHSCREENS","Graph Screens"); define("_AM_SCREEN_DELETESCREENS","Are you sure you want to delete this screen? All configuration settings for this screen will be lost!"); @@ -779,5 +780,6 @@ define("_AM_FORMULIZE_CLONING_CANBELINKEDTO", "can be linked to:"); define("_AM_FORMULIZE_CLONING_NOCHANGE", "keep it linked to its current source"); - +// Graph Screen Definitions +define("_AM_GRAPH_SCREEN_OPTIONS", "Graph Options"); ?> From 43bbd946ed14fea629d710b95661292195d91803 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 23 Feb 2014 05:38:04 -0800 Subject: [PATCH 09/40] lists screen graphs --- .../templates/admin/form_screens.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/formulize/templates/admin/form_screens.html b/modules/formulize/templates/admin/form_screens.html index 4478def87..6c298be27 100644 --- a/modules/formulize/templates/admin/form_screens.html +++ b/modules/formulize/templates/admin/form_screens.html @@ -60,6 +60,24 @@

<{$smarty.const._AM_SCREEN_LISTSCREENS}>

<{/foreach}>
+ +

<{$smarty.const._AM_SCREEN_GRAPHSCREENS}>

+
+ + + + + + + <{foreach from=$content.graphs item=screen}> + + + + + + <{/foreach}> +
NameidAction
<{$screen.sid}> View     Remove
+
From bb494dc03270c3604d01624bbea9a045a491178c Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 3 Mar 2014 14:02:14 -0800 Subject: [PATCH 10/40] new columns to the table --- modules/formulize/admin/formindex.php | 5 ++++- modules/formulize/sql/mysql.sql | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index 393925b7b..0a0deadf4 100755 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -112,7 +112,7 @@ function patch40() { * ====================================== */ $checkThisTable = 'formulize_screen_graph'; - $checkThisField = 'barb'; + $checkThisField = 'dataelem'; $checkThisProperty = false; $checkPropertyForValue = false; @@ -295,6 +295,9 @@ function patch40() { `barr` int(8) NOT NULL default 143, `barg` int(8) NOT NULL default 190, `barb` int(8) NOT NULL default 88, + 'ops' varchar(255) NOT NULL default 'count', + `labelelem` int(8) NOT NULL default 0, + `dataelem` int(8) NOT NULL default 0, PRIMARY KEY (`formid`), INDEX i_sid (`sid`) ) ENGINE=MyISAM;"; diff --git a/modules/formulize/sql/mysql.sql b/modules/formulize/sql/mysql.sql index a577d7869..6f8ec36e8 100755 --- a/modules/formulize/sql/mysql.sql +++ b/modules/formulize/sql/mysql.sql @@ -384,6 +384,9 @@ CREATE TABLE `formulize_screen_graph` ( `barr` int(8) NOT NULL default 143, `barg` int(8) NOT NULL default 190, `barb` int(8) NOT NULL default 88, + `ops` varchar(255) NOT NULL default 'count', + `labelelem` int(8) NOT NULL default 0, + `dataelem` int(8) NOT NULL default 0, PRIMARY KEY (`formid`), INDEX i_sid (`sid`) ) ENGINE=MyISAM; From fa59be9d75898d9ad9fccffca76aa99a59010807 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 3 Mar 2014 14:04:51 -0800 Subject: [PATCH 11/40] added new setting tab template, fixed some things --- .../templates/admin/screen_graph_cases.html | 45 +++++++++++++++++ .../templates/admin/screen_graph_options.html | 49 ++++++++++--------- .../templates/admin/screen_settings.html | 1 + modules/formulize/templates/admin/ui.html | 1 + modules/formulize/xoops_version.php | 3 ++ 5 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 modules/formulize/templates/admin/screen_graph_cases.html diff --git a/modules/formulize/templates/admin/screen_graph_cases.html b/modules/formulize/templates/admin/screen_graph_cases.html new file mode 100644 index 000000000..e6931d080 --- /dev/null +++ b/modules/formulize/templates/admin/screen_graph_cases.html @@ -0,0 +1,45 @@ +<{* form elements must be named with their object name hyphen field name *}> +<{* no other elements should have hyphens, since that tells the saving system that this is a property of an object to update *}> +<{* securitytoken should be part of the form *}> +<{* formulize_admin_handler and formulize_admin_key are required, to tell what the name of the save handling file is, and what the key is that we're inserting/updating on *}> + +
+<{$securitytoken}> + + + + +
+
+ User Cases +
+ + +
+
+
+ Graph Label Element +
+ + <{$content.labelelem}> +
+
+
+ Graph Data Element +
+ + <{$content.dataelem}> +
+
+
+ +
+ + \ No newline at end of file diff --git a/modules/formulize/templates/admin/screen_graph_options.html b/modules/formulize/templates/admin/screen_graph_options.html index 1ae6164f0..046706355 100644 --- a/modules/formulize/templates/admin/screen_graph_options.html +++ b/modules/formulize/templates/admin/screen_graph_options.html @@ -26,45 +26,50 @@
Background Color
- - -
-
- - -
-
- - +
+ + +
Bar Color
- - -
-
- - -
-
- - +
+ + +
\ No newline at end of file diff --git a/modules/formulize/templates/admin/screen_settings.html b/modules/formulize/templates/admin/screen_settings.html index 8802cf759..3e1062621 100644 --- a/modules/formulize/templates/admin/screen_settings.html +++ b/modules/formulize/templates/admin/screen_settings.html @@ -26,6 +26,7 @@ + <{if $content.sid neq 'new'}> diff --git a/modules/formulize/templates/admin/ui.html b/modules/formulize/templates/admin/ui.html index c86c8ab4d..838631ee6 100644 --- a/modules/formulize/templates/admin/ui.html +++ b/modules/formulize/templates/admin/ui.html @@ -1,6 +1,7 @@ + diff --git a/modules/formulize/xoops_version.php b/modules/formulize/xoops_version.php index 5cbbd011f..6d41adaa2 100644 --- a/modules/formulize/xoops_version.php +++ b/modules/formulize/xoops_version.php @@ -298,6 +298,9 @@ $modversion['templates'][] = array( 'file' => 'admin/screen_graph_options.html', 'description' => ''); +$modversion['templates'][] = array( + 'file' => 'admin/screen_graph_cases.html', + 'description' => ''); // Module Configs // $xoopsModuleConfig['t_width'] From 955db16638cb203ffbe39884a4a9103cd143358b Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 3 Mar 2014 14:05:33 -0800 Subject: [PATCH 12/40] the library for color picking --- modules/formulize/libraries/jscolor/arrow.gif | Bin 0 -> 66 bytes modules/formulize/libraries/jscolor/cross.gif | Bin 0 -> 83 bytes modules/formulize/libraries/jscolor/demo.html | 12 + modules/formulize/libraries/jscolor/hs.png | Bin 0 -> 2684 bytes modules/formulize/libraries/jscolor/hv.png | Bin 0 -> 2865 bytes .../formulize/libraries/jscolor/jscolor.js | 997 ++++++++++++++++++ 6 files changed, 1009 insertions(+) create mode 100644 modules/formulize/libraries/jscolor/arrow.gif create mode 100644 modules/formulize/libraries/jscolor/cross.gif create mode 100644 modules/formulize/libraries/jscolor/demo.html create mode 100644 modules/formulize/libraries/jscolor/hs.png create mode 100644 modules/formulize/libraries/jscolor/hv.png create mode 100644 modules/formulize/libraries/jscolor/jscolor.js diff --git a/modules/formulize/libraries/jscolor/arrow.gif b/modules/formulize/libraries/jscolor/arrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..246478a864f812d93d4cd0e0d0ad1c8e2d09c825 GIT binary patch literal 66 zcmZ?wbhEHbWM|-JSjfZx1poj4Utv=LM2bII7`Ygj7<53QAbAERVV@R>f}L*~a`L;Z PKCZl?^}@uHk--`OML81Y literal 0 HcmV?d00001 diff --git a/modules/formulize/libraries/jscolor/cross.gif b/modules/formulize/libraries/jscolor/cross.gif new file mode 100644 index 0000000000000000000000000000000000000000..0ee9c7ac517bee40b78aea03afa809631f0b69fa GIT binary patch literal 83 zcmZ?wbhEHb + + jscolor demo + + + + + + Click here: + + + diff --git a/modules/formulize/libraries/jscolor/hs.png b/modules/formulize/libraries/jscolor/hs.png new file mode 100644 index 0000000000000000000000000000000000000000..3d94486cedaf7111d010fdaf2cefad45fd1f878b GIT binary patch literal 2684 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 YzFqsNg>|5V=vOIWZ|#VBZRvIQe;Bk#LI3~& literal 0 HcmV?d00001 diff --git a/modules/formulize/libraries/jscolor/hv.png b/modules/formulize/libraries/jscolor/hv.png new file mode 100644 index 0000000000000000000000000000000000000000..1c5e01f8bcecc4cf835e8eeeaa43ef2c06789022 GIT binary patch literal 2865 zcmX9=3pmqV7@teXHB3Y-6(VIKN(`gs(lEJ2EJSn5Crm8<3KhyeDHUOICnT3LV_lSr zSZ;GyqBJp=+1PCR_SJKqbI$X;=RD_m-{1TDz3)kPaYD#Qs!D=DAQ^i*TUWu}ESNzO z!h$tb?&uc~NOHs8*4pjL*kZxr-PxxyX>x_gxykAYer+%xw7GJL6<~$lv;J_uukT@e zT+7b}$(pn*(JJ8$DZ#LZ01jlU-F%s?>x-3}&1jWkz{Hc;TVcidNj^67rKf!1D*@3) ztLL+`4RJ%9hMug+6V6!!-IHycuV!0OlQmpmv2CKSg0YG1{n}Dwm~{0fWmk@tnE%bH zGDMD}$zh}Xd*A5Jr>Ab?KaI7@rj$4go;`Iq6;(c5H(>=6GfP&HNa3NNYQLnDvJ2ne z$YJeDOOojN`RsDxcPJ(@V2^adMpBgs?_RszQhhwQTbkTUT9<$&gblmnY#tn#SD%?s z6!FjP;K)%vq`iXljQbV;EA`q3gN>D#kt_%-rrtu}_V)B!9x+O;F>_Uw;U$2LUW(r( zZ^t$jiL0NIPPJC#r9ftBYTo7JNd@BVMwfPoS>#W-s{js57)P8TQqF2LKJSC~q zN`(OhzStrI{*42`M}?+OHN|N(nHmc2&ss7X>pqp|EuFchzf#w`Q<>0h788{$3pLsi z{A+Y8H$ZvOeD+cX_=w?G*WmD7#5x;KQ;esP!0)6)^5AH8-y+H+(ltKN1HTE6jI?K z(Oj2zOym!q0yMO-dc+a4KFGVLQdOCayj7RKSbo5}XS%`Er&=Enk8l=Lt4N_|ws%>z zDTw$}Y`Nm#m5bv zhmbvJfbg?pPsmqI$V;VUb6K4%(8Blyamyoc^3Mt~#nxOV2-1;QS z7!g7Xk6~wu3v&9INnRdHE*gAiCyeFJfduHa!!F*?W}`Rm+67%Q2s@LIH)iL^`wkK? zP=B5?DxX)2ei6KWxu`4O*JwZU+*(Cn+LV2vEPKLR@_s$KUT7@2PHFKwyIUh>^m?5T z#Wg9M+ONj0h5LZ>!IpK?OV*wMW)AaJ>s;#DyjnhJJV%E}HpnL*e41CBd!#oRt0hRq zD7&FLe2(1tZe#9{PBC=l7=zkzp0E>J}%G@Q)V(&5;V; z_Ip{Z1E&&~f`Si(E^g}CJnwWVfQ{%Unn?l%XMGXgcA?zDBpPe^pO`J?UGQi2^T4)IUfoOnd(>JAQ8aPg@ zB_;;xwvXzblZt7u^BsB>aU@zJE1ch*TlQwuWu7BDuKT{66^RATo0B+Y!@Lhy1GSwWwEi=Q+}{?yp8BIm>I-u0&;G(EAzl`dWB zRwuQl%yBKwtv`^NR}gNuzg>8Y(x1DoZboBm7h9&Lhd6FL<64*y8ZDcoR+2S>La>P{ zdT}{ovrGh|#CyWM!R~Nh2aG>ZjO+}-icsKGb<8`S26!F3nT0k<6$)RZuei(y1^m-V z`FzfUFvRX2AB~LzUAD`t4sh4+X?+2kj20+cq*#lahA)7AosJ-k#=;GD*U}97uFLKj zo^@6(zQe&aeK^$2IN*IzWO-uxdlY3#5IvJ?Va5_yC8^$xf6c)Wz8!vpPzq^I#s8-J zYyM?GrR0`h}1un-M;JJa=H9Ncb^MF#<$~pqrt4epF8nadCmVNKJuIWM9YdYW&cwO1A~wUN zrd-jpV#03i+W0W%1&nO}Uy!h7u>^0`~OuH_{)(AjBe;hsQ!*)mO_DzpGRC zyox}(f&d2Gpi6^iw#eB7bVT;3FFa@cC>tM0 zh`Tj?={tK()4_woqpfX-$RrW>1rj>)NVFkyuySiiw7RSW_`4Px7jCb2c4SAc`*^t$*(d zB&ak&1Rbch68*E0=N1vmji9yfXFnH>R$*ue>|7dPIO)*efxInfOwf5~K+Ou1gVxLJ znHJS9zagvG#*KbWDL=8YuMi#xgFQZk9Mq{0A}gF)8u?-xvaEZdtqyUFRTrLq*p?!~??u&DrIz2ow@FRy0XX+-+%7G>uU0&kTN1W1G| zr>H6)4|9Ji%2`d{EBb%`9?5PNx968;9+OmY4|DC?&+M;;jN=L6in4xY&Q$twq0QFAeZuQ15|q?2tO{QUL* E0LKozl>h($ literal 0 HcmV?d00001 diff --git a/modules/formulize/libraries/jscolor/jscolor.js b/modules/formulize/libraries/jscolor/jscolor.js new file mode 100644 index 000000000..6bb0c1f4a --- /dev/null +++ b/modules/formulize/libraries/jscolor/jscolor.js @@ -0,0 +1,997 @@ +/** + * jscolor, JavaScript Color Picker + * + * @version 1.4.2 + * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html + * @author Jan Odvarko, http://odvarko.cz + * @created 2008-06-15 + * @updated 2013-11-25 + * @link http://jscolor.com + */ + + +var jscolor = { + + + dir : '', // location of jscolor directory (leave empty to autodetect) + bindClass : 'color', // class name + binding : true, // automatic binding via + preloading : true, // use image preloading? + + + install : function() { + jscolor.addEvent(window, 'load', jscolor.init); + }, + + + init : function() { + if(jscolor.binding) { + jscolor.bind(); + } + if(jscolor.preloading) { + jscolor.preload(); + } + }, + + + getDir : function() { + if(!jscolor.dir) { + var detected = jscolor.detectDir(); + jscolor.dir = detected!==false ? detected : 'jscolor/'; + } + return jscolor.dir; + }, + + + detectDir : function() { + var base = location.href; + + var e = document.getElementsByTagName('base'); + for(var i=0; i vs[a] ? + (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : + tp[a], + -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? + (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : + (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) + ]; + } + drawPicker(pp[a], pp[b]); + } + }; + + + this.importColor = function() { + if(!valueElement) { + this.exportColor(); + } else { + if(!this.adjust) { + if(!this.fromString(valueElement.value, leaveValue)) { + styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; + styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; + styleElement.style.color = styleElement.jscStyle.color; + this.exportColor(leaveValue | leaveStyle); + } + } else if(!this.required && /^\s*$/.test(valueElement.value)) { + valueElement.value = ''; + styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; + styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; + styleElement.style.color = styleElement.jscStyle.color; + this.exportColor(leaveValue | leaveStyle); + + } else if(this.fromString(valueElement.value)) { + // OK + } else { + this.exportColor(); + } + } + }; + + + this.exportColor = function(flags) { + if(!(flags & leaveValue) && valueElement) { + var value = this.toString(); + if(this.caps) { value = value.toUpperCase(); } + if(this.hash) { value = '#'+value; } + valueElement.value = value; + } + if(!(flags & leaveStyle) && styleElement) { + styleElement.style.backgroundImage = "none"; + styleElement.style.backgroundColor = + '#'+this.toString(); + styleElement.style.color = + 0.213 * this.rgb[0] + + 0.715 * this.rgb[1] + + 0.072 * this.rgb[2] + < 0.5 ? '#FFF' : '#000'; + } + if(!(flags & leavePad) && isPickerOwner()) { + redrawPad(); + } + if(!(flags & leaveSld) && isPickerOwner()) { + redrawSld(); + } + }; + + + this.fromHSV = function(h, s, v, flags) { // null = don't change + if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); } + if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); } + if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); } + + this.rgb = HSV_RGB( + h===null ? this.hsv[0] : (this.hsv[0]=h), + s===null ? this.hsv[1] : (this.hsv[1]=s), + v===null ? this.hsv[2] : (this.hsv[2]=v) + ); + + this.exportColor(flags); + }; + + + this.fromRGB = function(r, g, b, flags) { // null = don't change + if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); } + if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); } + if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); } + + var hsv = RGB_HSV( + r===null ? this.rgb[0] : r, + g===null ? this.rgb[1] : g, + b===null ? this.rgb[2] : b + ); + if(hsv[0] !== null) { + this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0])); + } + if(hsv[2] !== 0) { + this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1])); + } + this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2])); + + // update RGB according to final HSV, as some values might be trimmed + var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); + this.rgb[0] = rgb[0]; + this.rgb[1] = rgb[1]; + this.rgb[2] = rgb[2]; + + this.exportColor(flags); + }; + + + this.fromString = function(hex, flags) { + var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i); + if(!m) { + return false; + } else { + if(m[1].length === 6) { // 6-char notation + this.fromRGB( + parseInt(m[1].substr(0,2),16) / 255, + parseInt(m[1].substr(2,2),16) / 255, + parseInt(m[1].substr(4,2),16) / 255, + flags + ); + } else { // 3-char notation + this.fromRGB( + parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255, + parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255, + parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255, + flags + ); + } + return true; + } + }; + + + this.toString = function() { + return ( + (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) + + (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) + + (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1) + ); + }; + + + function RGB_HSV(r, g, b) { + var n = Math.min(Math.min(r,g),b); + var v = Math.max(Math.max(r,g),b); + var m = v - n; + if(m === 0) { return [ null, 0, v ]; } + var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); + return [ h===6?0:h, m/v, v ]; + } + + + function HSV_RGB(h, s, v) { + if(h === null) { return [ v, v, v ]; } + var i = Math.floor(h); + var f = i%2 ? h-i : 1-(h-i); + var m = v * (1 - s); + var n = v * (1 - s*f); + switch(i) { + case 6: + case 0: return [v,n,m]; + case 1: return [n,v,m]; + case 2: return [m,v,n]; + case 3: return [m,n,v]; + case 4: return [n,m,v]; + case 5: return [v,m,n]; + } + } + + + function removePicker() { + delete jscolor.picker.owner; + document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB); + } + + + function drawPicker(x, y) { + if(!jscolor.picker) { + jscolor.picker = { + box : document.createElement('div'), + boxB : document.createElement('div'), + pad : document.createElement('div'), + padB : document.createElement('div'), + padM : document.createElement('div'), + sld : document.createElement('div'), + sldB : document.createElement('div'), + sldM : document.createElement('div'), + btn : document.createElement('div'), + btnS : document.createElement('span'), + btnT : document.createTextNode(THIS.pickerCloseText) + }; + for(var i=0,segSize=4; i Date: Mon, 3 Mar 2014 14:06:40 -0800 Subject: [PATCH 13/40] more files for the new template --- .../admin/save/screen_graph_cases_save.php | 39 +++++++++++++++++++ modules/formulize/language/english/admin.php | 1 + 2 files changed, 40 insertions(+) create mode 100644 modules/formulize/admin/save/screen_graph_cases_save.php diff --git a/modules/formulize/admin/save/screen_graph_cases_save.php b/modules/formulize/admin/save/screen_graph_cases_save.php new file mode 100644 index 000000000..e77dc38a9 --- /dev/null +++ b/modules/formulize/admin/save/screen_graph_cases_save.php @@ -0,0 +1,39 @@ +get($sid); + +// CHECK IF THE FORM IS LOCKED DOWN AND SCOOT IF SO +$form_handler = xoops_getmodulehandler('forms', 'formulize'); +$formObject = $form_handler->get($screen->getVar('fid')); +if($formObject->getVar('lockedform')) { + return; +} +// check if the user has permission to edit the form +if(!$gperm_handler->checkRight("edit_form", $screen->getVar('fid'), $groups, $mid)) { + return; +} + + +$screen->setVar('ops',$screens['ops']); +$screen->setVar('labelelem',$screens['labelelem']); +$screen->setVar('dataelem',$screens['dataelem']); + + +if(!$screen_handler->insert($screen)) { + print "Error: could not save the screen properly: ".mysql_error(); +} +?> diff --git a/modules/formulize/language/english/admin.php b/modules/formulize/language/english/admin.php index 3daef3d9d..0d2ca6026 100644 --- a/modules/formulize/language/english/admin.php +++ b/modules/formulize/language/english/admin.php @@ -782,4 +782,5 @@ // Graph Screen Definitions define("_AM_GRAPH_SCREEN_OPTIONS", "Graph Options"); +define("_AM_GRAPH_SCREEN_CASES", "Graph Cases"); ?> From 95082ffb11651eeba9243723de8b58eefd4385bc Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 3 Mar 2014 14:08:04 -0800 Subject: [PATCH 14/40] updated graph screen with new fields, and bunch of fixes --- modules/formulize/admin/screen.php | 9 ++++ modules/formulize/class/graphScreen.php | 56 +++++++++---------------- modules/formulize/include/functions.php | 3 +- 3 files changed, 29 insertions(+), 39 deletions(-) diff --git a/modules/formulize/admin/screen.php b/modules/formulize/admin/screen.php index 2ea531661..e73677ea9 100644 --- a/modules/formulize/admin/screen.php +++ b/modules/formulize/admin/screen.php @@ -403,6 +403,11 @@ function multiPageScreen_addToOptionsList($form_id, $options) { $graph_options['barr'] = $screen->getVar('barr'); $graph_options['barg'] = $screen->getVar('barg'); $graph_options['barb'] = $screen->getVar('barb'); + $graph_options['ops'] = $screen->getVar('ops'); + list($labelelem, $selectedlabelelem) = createFieldList($screen->getVar('labelelem'), false, false, "screens-labelelem", "Choose one"); + $graph_options['labelelem'] = $labelelem->render(); + list($dataelem, $selecteddataelem) = createFieldList($screen->getVar('dataelem'), false, false, "screens-dataelem", "Choose one"); + $graph_options['dataelem'] = $dataelem->render(); } // common values should be assigned to all tabs @@ -475,6 +480,10 @@ function multiPageScreen_addToOptionsList($form_id, $options) { $adminPage['tabs'][2]['name'] = _AM_GRAPH_SCREEN_OPTIONS; $adminPage['tabs'][2]['template'] = "db:admin/screen_graph_options.html"; $adminPage['tabs'][2]['content'] = $graph_options + $common; + + $adminPage['tabs'][3]['name'] = _AM_GRAPH_SCREEN_CASES; + $adminPage['tabs'][3]['template'] = "db:admin/screen_graph_cases.html"; + $adminPage['tabs'][3]['content'] = $graph_options + $common; } $adminPage['pagetitle'] = _AM_FORM_SCREEN.$screenName; diff --git a/modules/formulize/class/graphScreen.php b/modules/formulize/class/graphScreen.php index f72be42a6..441273070 100644 --- a/modules/formulize/class/graphScreen.php +++ b/modules/formulize/class/graphScreen.php @@ -20,6 +20,9 @@ function formulizeGraphScreen() { $this->initvar("barr", XOBJ_DTYPE_INT); $this->initvar("barg", XOBJ_DTYPE_INT); $this->initvar("barb", XOBJ_DTYPE_INT); + $this->initvar("ops", XOBJ_DTYPE_TXTBOX, NULL, false, 255); + $this->initvar("labelelem", XOBJ_DTYPE_INT); + $this->initvar("dataelem", XOBJ_DTYPE_INT); } } @@ -56,9 +59,9 @@ function insert($screen) { $screen->setVar('dobr', 0); // note: conditions is not written to the DB yet, since we're not gathering that info from the UI if (!$update) { - $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb')); + $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb, ops, labelelem, dataelem) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u, %s, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $screen->getVar('ops')); } else { - $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $screen->getVar('sid')); + $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u, ops = %s, labelelem = %u, dataelem = %u WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $screen->getVar('sid')); } $result = $this->db->query($sql); if (!$result) { @@ -90,46 +93,25 @@ function get($sid) { // THIS METHOD HANDLES ALL THE LOGIC ABOUT HOW TO ACTUALLY DISPLAY THIS TYPE OF SCREEN // $screen is a screen object function render($screen, $entry, $settings = "") { // $settings is used internally to pass list of entries settings back and forth to editing screens - /* - if(!is_array($settings)) { - $settings = ""; - } - $formframe = $screen->getVar('frid') ? $screen->getVar('frid') : $screen->getVar('fid'); - $mainform = $screen->getVar('frid') ? $screen->getVar('fid') : ""; - $donedest = $screen->getVar("donedest"); - $savebuttontext = $screen->getVar("savebuttontext"); - $savebuttontext = $savebuttontext ? $savebuttontext : _formulize_SAVE; - $alldonebuttontext = $screen->getVar("alldonebuttontext"); - $alldonebuttontext = $alldonebuttontext ? $alldonebuttontext : "{NOBUTTON}"; - $displayheading = $screen->getVar('displayheading'); - $displayheading = $displayheading ? "" : "all"; // if displayheading is off, then need to pass the "all" keyword to supress all the headers - $reloadblank = $screen->getVar('reloadblank'); - // figure out the form's properties... - // if it's more than one entry per user, and we have requested reload blank, then override multi is 0, otherwise 1 - // if it's one entry per user, and we have requested reload blank, then override multi is 1, otherwise 0 - $form_handler = xoops_getmodulehandler('forms', 'formulize'); - $formObject = $form_handler->get($screen->getVar('fid')); - if($formObject->getVar('single')=="off" AND $reloadblank) { - $overrideMulti = 0; - } elseif($formObject->getVar('single')=="off" AND !$reloadblank) { - $overrideMulti = 1; - } elseif(($formObject->getVar('single')=="group" OR $formObject->getVar('single')=="user") AND $reloadblank) { - $overrideMulti = 1; - } elseif(($formObject->getVar('single')=="group" OR $formObject->getVar('single')=="user") AND !$reloadblank) { - $overrideMulti = 0; - } else { - $overrideMulti = 0; - } - include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplay.php"; - displayForm($formframe, $entry, $mainform, $donedest, array(0=>$alldonebuttontext, 1=>$savebuttontext), - $settings, $displayheading, "", $overrideMulti, "", 0, 0, 0, $screen); - */ + $bgc = [ + "R" => $screen->getVar('bgr'), + "G" => $screen->getVar('bgg'), + "B" => $screen->getVar('bgb') + ]; + $barc = [ + "R" => $screen->getVar('barr'), + "G" => $screen->getVar('barg'), + "B" => $screen->getVar('barb') + ]; $options = [ "width" => $screen->getVar('width'), "height" => $screen->getVar('height'), + "orientation" => $screen->getVar('orientation'), + "backgroundcolor" => $bgc, + "barcolor" => $barc ]; include_once XOOPS_ROOT_PATH."/modules/formulize/include/graphdisplay.php"; - displayGraph('Bar', $screen->getVar('fid'), $screen->getVar('frid'), 2, 2, 'sum', $options); + displayGraph('Bar', $screen->getVar('fid'), $screen->getVar('frid'), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $screen->getVar('ops'), $options); } } ?> diff --git a/modules/formulize/include/functions.php b/modules/formulize/include/functions.php index 8da9a8239..4a0237de2 100644 --- a/modules/formulize/include/functions.php +++ b/modules/formulize/include/functions.php @@ -2156,9 +2156,8 @@ function createFieldList($val, $textbox=false, $limitToForm=false, $name="", $fi // write formname: caption to the master array that will be passed to the select box. $totalcaptionlist[$captionlistindex] = printSmart(trans($rowformlist[1])) . ": " . printSmart(trans($rowfieldnames[0]), 50); $totalvaluelist[$captionlistindex] = $rowfieldnames[1]; - // if this is the selected entry - if ($val == $totalvaluelist[$captionlistindex] OR $val == $rowformlist[0] . "#*=:*" . $rowfieldnames[2]) { + if ($val == $totalvaluelist[$captionlistindex] OR $val === ($rowformlist[0] . "#*=:*" . $rowfieldnames[2])) { $defaultlinkselection = $captionlistindex; } $captionlistindex++; From 1c27f5ed2089c0a5daa1378f9f74b4813a339571 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 10 Mar 2014 00:28:39 -0700 Subject: [PATCH 15/40] added name sanitizing function --- modules/formulize/include/functions.php | 5 +++++ modules/formulize/include/graphdisplay.php | 1 + 2 files changed, 6 insertions(+) diff --git a/modules/formulize/include/functions.php b/modules/formulize/include/functions.php index 4a0237de2..970232de8 100644 --- a/modules/formulize/include/functions.php +++ b/modules/formulize/include/functions.php @@ -4965,4 +4965,9 @@ function formulize_escape($value) { $value = $xoopsDB->quote($value); return substr($value, 1,-1); } +} + +// strip non-alphanumeric characters +function sanitize_name($name) { + return preg_replace("/[^a-zA-Z0-9_]+/", "", $name); } \ No newline at end of file diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index 96f2a8450..f31c63763 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -366,6 +366,7 @@ function renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $oper // TODO: make some kind of cron job clear up or some kind of caches, update graph only when needed! $grapRelativePathPrefix = "modules/formulize/images/graphs/"; $graphRelativePath = $grapRelativePathPrefix . "_" . $fid . "_" . "_" . $frid . "_" . $labelElement . "_" . $dataElement . "_" . "$operation" . "_" . preg_replace('/[^\w\d]/', "", print_r($graphOptions, true)) . ".png"; + $graphRelativePath = sanitize_name($graphRelativePath); $myPicture -> render(XOOPS_ROOT_PATH . "/" . $graphRelativePath); echo ""; return; From 9df4eed2cdf0387930cc7e3dd2810706bc478a7a Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 10 Mar 2014 11:58:43 -0700 Subject: [PATCH 16/40] fixed sql query --- modules/formulize/class/graphScreen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/formulize/class/graphScreen.php b/modules/formulize/class/graphScreen.php index 441273070..582f35529 100644 --- a/modules/formulize/class/graphScreen.php +++ b/modules/formulize/class/graphScreen.php @@ -59,7 +59,7 @@ function insert($screen) { $screen->setVar('dobr', 0); // note: conditions is not written to the DB yet, since we're not gathering that info from the UI if (!$update) { - $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb, ops, labelelem, dataelem) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u, %s, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $screen->getVar('ops')); + $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb, ops, labelelem, dataelem) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u, %s, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem')); } else { $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u, ops = %s, labelelem = %u, dataelem = %u WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $screen->getVar('sid')); } From cbd09c8059416f42b3d75602d1c3e8bbe3cd8328 Mon Sep 17 00:00:00 2001 From: Daniel Ferguson Date: Mon, 10 Mar 2014 17:45:17 -0700 Subject: [PATCH 17/40] Fix quotes in table creation statement. --- modules/formulize/admin/formindex.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index 0a0deadf4..528ac2e61 100755 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -295,7 +295,7 @@ function patch40() { `barr` int(8) NOT NULL default 143, `barg` int(8) NOT NULL default 190, `barb` int(8) NOT NULL default 88, - 'ops' varchar(255) NOT NULL default 'count', + `ops` varchar(255) NOT NULL default 'count', `labelelem` int(8) NOT NULL default 0, `dataelem` int(8) NOT NULL default 0, PRIMARY KEY (`formid`), From 3be7a962187471926eae8d37a19c50a8fd2eb7ab Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 24 Mar 2014 00:30:05 -0700 Subject: [PATCH 18/40] Changed graph image naming, added an example for the bug --- modules/formulize/include/graphdisplay.php | 28 +++++---- .../pChart/examples/graphdisplayex.php | 60 +++++++++++++++++++ 2 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 modules/formulize/libraries/pChart/examples/graphdisplayex.php diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index f31c63763..a88995cc7 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -309,13 +309,19 @@ function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $ $myData -> setAbscissa($labelElement); $myData -> setAbscissaName($labelElement); // $myData -> setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat"); + print_r($dataPoints); + print_r(array_values($dataPoints)); + print_r(array_keys($dataPoints)); + print_r(Array(2000000, 600000, 12000000)); + print_r(array("San Fransisco", "Seattle", "New York")); + print $IMAGE_WIDTH . " " . $IMAGE_HEIGHT . " " . $IMAGE_ORIENTATION . " " . $BARCOLOR_R . " " . $BARCOLOR_G . " " . $BARCOLOR_B . " " . $sizeMultiplier . " " . $BACKGROUND_R . " " . $BACKGROUND_G . " " . $BACKGROUND_B; /* Create the pChart object */ $myPicture = new pImage($IMAGE_WIDTH, $IMAGE_HEIGHT, $myData); $myPicture -> drawGradientArea(0, 0, $IMAGE_WIDTH, $IMAGE_HEIGHT, DIRECTION_VERTICAL, array("StartR" => $BACKGROUND_R, "StartG" => $BACKGROUND_G, "StartB" => $BACKGROUND_B, "EndR" => $BACKGROUND_R, "EndG" => $BACKGROUND_G, "EndB" => $BACKGROUND_B, "Alpha" => 100)); - $myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>30)); + $myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>30)); $myPicture -> setFontProperties(array("FontName" => "modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8)); - + $paddingtoLeft = $IMAGE_WIDTH * 0.15; $paddingtoTop = $IMAGE_HEIGHT * 0.2; if( $paddingtoTop > 50){ @@ -324,24 +330,24 @@ function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $ /* Draw the chart scale */ $myPicture -> setGraphArea($paddingtoLeft, $paddingtoTop, $IMAGE_WIDTH * 0.90, $IMAGE_HEIGHT * 0.88); - + if($IMAGE_ORIENTATION == "vertical"){ $myPicture -> drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50)); }else{ $myPicture -> drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50)); } - + /* Turn on shadow computing */ $myPicture -> setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); - + $Palette = array("0"=>array("R"=>$BARCOLOR_R,"G"=>$BARCOLOR_G,"B"=>$BARCOLOR_B,"Alpha"=>100)); - + for($i = 1 ; $i < $sizeMultiplier ; $i++){ $Palette[$i] = array("R"=>$BARCOLOR_R,"G"=>$BARCOLOR_G,"B"=>$BARCOLOR_B,"Alpha"=>100); } - + // print_r($Palette); - + $myPicture->drawBarChart(array("OverrideColors"=>$Palette)); /* Draw the chart */ @@ -364,9 +370,9 @@ function YAxisFormat($Value) { */ function renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions) { // TODO: make some kind of cron job clear up or some kind of caches, update graph only when needed! - $grapRelativePathPrefix = "modules/formulize/images/graphs/"; - $graphRelativePath = $grapRelativePathPrefix . "_" . $fid . "_" . "_" . $frid . "_" . $labelElement . "_" . $dataElement . "_" . "$operation" . "_" . preg_replace('/[^\w\d]/', "", print_r($graphOptions, true)) . ".png"; - $graphRelativePath = sanitize_name($graphRelativePath); + $graphRelativePathPrefix = "modules/formulize/images/graphs/"; + // Uses md5 hash of the data points and graph options to shorten filename and handle non alphanumeric chars + $graphRelativePath = $graphRelativePathPrefix . md5(SDATA_DB_SALT.var_export($dataPoints, true).var_export($graphOptions, true)).".png"; $myPicture -> render(XOOPS_ROOT_PATH . "/" . $graphRelativePath); echo ""; return; diff --git a/modules/formulize/libraries/pChart/examples/graphdisplayex.php b/modules/formulize/libraries/pChart/examples/graphdisplayex.php new file mode 100644 index 000000000..70d61a2cd --- /dev/null +++ b/modules/formulize/libraries/pChart/examples/graphdisplayex.php @@ -0,0 +1,60 @@ +addPoints(Array(2000000, 600000, 12000000),"sum of City Population"); + $MyData->setAxisName(0,"sum of City Population"); + $MyData->addPoints(array("San Fransisco", "Seattle", "New York"),"City Name"); + $MyData->setSerieDescription("City Name","City Name"); + $MyData->setAbscissa("City Name"); + $MyData->setAbscissaName("City Name"); + //$MyData->setAxisDisplay(0,AXIS_FORMAT_METRIC,1); + +/* Create the pChart object */ +$myPicture = new pImage(500, 300, $MyData); +$myPicture -> drawGradientArea(0, 0, 500, 300, DIRECTION_VERTICAL, array("StartR" => 225, "StartG" => 22, "StartB" => 22, "EndR" => 225, "EndG" => 22, "EndB" => 22, "Alpha" => 100)); +$myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>30)); +$myPicture -> setFontProperties(array("FontName" => "../fonts/arial.ttf", "FontSize" => 8)); + +$paddingtoLeft = 500 * 0.15; +$paddingtoTop = 300 * 0.2; +if( $paddingtoTop > 50){ + $paddingtoTop = 50; +} + +/* Draw the chart scale */ +$myPicture -> setGraphArea($paddingtoLeft, $paddingtoTop, 500 * 0.90, 300 * 0.88); + +if("vertical" == "vertical"){ + $myPicture -> drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50)); +}else{ + $myPicture -> drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50)); +} + +/* Turn on shadow computing */ +$myPicture -> setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); + +$Palette = array("0"=>array("R"=>190,"G"=>106,"B"=>70,"Alpha"=>100)); + +for($i = 1 ; $i < 3 ; $i++){ + $Palette[$i] = array("R"=>190,"G"=>106,"B"=>70,"Alpha"=>100); +} + +// print_r($Palette); + +$myPicture->drawBarChart(array("OverrideColors"=>$Palette)); + +/* Draw the chart */ +$myPicture -> drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors"=>$Palette)); + + + + /* Render the picture (choose the best way) */ + $myPicture->autoOutput("pictures/example.drawBarChart.vertical.png"); +?> \ No newline at end of file From 05ae456a27c1efb2cb4610f2e4a8ca68d1e5c7c7 Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Fri, 28 Mar 2014 01:16:47 -0700 Subject: [PATCH 19/40] fixed label bug --- modules/formulize/include/graphdisplay.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index a88995cc7..9eb6cfa14 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -296,9 +296,9 @@ function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $ $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT/4.5-3)."..."; } } - - - + + + // Code straightly copied from pChart documentation to draw the graph $myData = new pData(); @@ -309,18 +309,12 @@ function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $ $myData -> setAbscissa($labelElement); $myData -> setAbscissaName($labelElement); // $myData -> setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat"); - print_r($dataPoints); - print_r(array_values($dataPoints)); - print_r(array_keys($dataPoints)); - print_r(Array(2000000, 600000, 12000000)); - print_r(array("San Fransisco", "Seattle", "New York")); - print $IMAGE_WIDTH . " " . $IMAGE_HEIGHT . " " . $IMAGE_ORIENTATION . " " . $BARCOLOR_R . " " . $BARCOLOR_G . " " . $BARCOLOR_B . " " . $sizeMultiplier . " " . $BACKGROUND_R . " " . $BACKGROUND_G . " " . $BACKGROUND_B; /* Create the pChart object */ $myPicture = new pImage($IMAGE_WIDTH, $IMAGE_HEIGHT, $myData); $myPicture -> drawGradientArea(0, 0, $IMAGE_WIDTH, $IMAGE_HEIGHT, DIRECTION_VERTICAL, array("StartR" => $BACKGROUND_R, "StartG" => $BACKGROUND_G, "StartB" => $BACKGROUND_B, "EndR" => $BACKGROUND_R, "EndG" => $BACKGROUND_G, "EndB" => $BACKGROUND_B, "Alpha" => 100)); $myPicture->drawGradientArea(0,0,500,500,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>30)); - $myPicture -> setFontProperties(array("FontName" => "modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8)); + $myPicture -> setFontProperties(array("FontName" => XOOPS_ROOT_PATH . "/modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8)); $paddingtoLeft = $IMAGE_WIDTH * 0.15; $paddingtoTop = $IMAGE_HEIGHT * 0.2; From 0cf9f4cd0388457baed6c1b3f6ee989b7f9ec64e Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Sun, 30 Mar 2014 23:48:02 -0700 Subject: [PATCH 20/40] a bunch of code from entries display, not working yet --- modules/formulize/include/graphdisplay.php | 682 ++++++++++++++++++++- 1 file changed, 681 insertions(+), 1 deletion(-) diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index 9eb6cfa14..e0231cfcf 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -362,13 +362,111 @@ function YAxisFormat($Value) { /** * Save the graph to the local file system and render the graph */ -function renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions) { +function renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions) { // establish text and code for buttons, whether a screen is in effect or not + $screenButtonText = array(); + $screenButtonText['modifyScreenLink'] = ($edit_form AND $screen) ? _formulize_DE_MODIFYSCREEN : ""; + $screenButtonText['changeColsButton'] = _formulize_DE_CHANGECOLS; + $screenButtonText['calcButton'] = _formulize_DE_CALCS; + $screenButtonText['advCalcButton'] = _formulize_DE_ADVCALCS; + $screenButtonText['advSearchButton'] = _formulize_DE_ADVSEARCH; + $screenButtonText['exportButton'] = _formulize_DE_EXPORT; + $screenButtonText['exportCalcsButton'] = _formulize_DE_EXPORT_CALCS; + $screenButtonText['importButton'] = _formulize_DE_IMPORTDATA; + $screenButtonText['notifButton'] = _formulize_DE_NOTBUTTON; + $screenButtonText['cloneButton'] = _formulize_DE_CLONESEL; + $screenButtonText['deleteButton'] = _formulize_DE_DELETESEL; + $screenButtonText['selectAllButton'] = _formulize_DE_SELALL; + $screenButtonText['clearSelectButton'] = _formulize_DE_CLEARALL; + $screenButtonText['resetViewButton'] = _formulize_DE_RESETVIEW; + $screenButtonText['saveViewButton'] = _formulize_DE_SAVE; + $screenButtonText['deleteViewButton'] = _formulize_DE_DELETE; + $screenButtonText['currentViewList'] = _formulize_DE_CURRENT_VIEW; + $screenButtonText['saveButton'] = _formulize_SAVE; + $screenButtonText['addButton'] = $singleMulti[0]['singleentry'] == "" ? _formulize_DE_ADDENTRY : _formulize_DE_UPDATEENTRY; + $screenButtonText['addMultiButton'] = _formulize_DE_ADD_MULTIPLE_ENTRY; + $screenButtonText['addProxyButton'] = _formulize_DE_PROXYENTRY; + if($screen) { + if($add_own_entry) { + $screenButtonText['addButton'] = $screen->getVar('useaddupdate'); + $screenButtonText['addMultiButton'] = $screen->getVar('useaddmultiple'); + } else { + $screenButtonText['addButton'] = ""; + $screenButtonText['addMultiButton'] = ""; + } + if($proxy) { + $screenButtonText['addProxyButton'] = $screen->getVar('useaddproxy'); + } else { + $screenButtonText['addProxyButton'] = ""; + } + $screenButtonText['exportButton'] = $screen->getVar('useexport'); + $screenButtonText['importButton'] = $screen->getVar('useimport'); + $screenButtonText['notifButton'] = $screen->getVar('usenotifications'); + $screenButtonText['currentViewList'] = $screen->getVar('usecurrentviewlist'); + $screenButtonText['saveButton'] = $screen->getVar('desavetext'); + $screenButtonText['changeColsButton'] = $screen->getVar('usechangecols'); + $screenButtonText['calcButton'] = $screen->getVar('usecalcs'); + $screenButtonText['advCalcButton'] = $screen->getVar('useadvcalcs'); + $screenButtonText['advSearchButton'] = $screen->getVar('useadvsearch'); + $screenButtonText['exportCalcsButton'] = $screen->getVar('useexportcalcs'); + // only include clone and delete if the checkboxes are in effect (2 means do not use checkboxes) + if($screen->getVar('usecheckboxes') != 2) { + $screenButtonText['cloneButton'] = $screen->getVar('useclone'); + if ($user_can_delete and !$settings['lockcontrols']) { + $screenButtonText['deleteButton'] = $screen->getVar('usedelete'); + } else { + $screenButtonText['deleteButton'] = ""; + } + $screenButtonText['selectAllButton'] = $screen->getVar('useselectall'); + $screenButtonText['clearSelectButton'] = $screen->getVar('useclearall'); + } else { + $screenButtonText['cloneButton'] = ""; + $screenButtonText['deleteButton'] = ""; + $screenButtonText['selectAllButton'] = ""; + $screenButtonText['clearSelectButton'] = ""; + } + // only include the reset, save, deleteview buttons if the current view list is in effect + if($screen->getVar('usecurrentviewlist')) { + $screenButtonText['resetViewButton'] = $screen->getVar('usereset'); + $screenButtonText['saveViewButton'] = $screen->getVar('usesave'); + $screenButtonText['deleteViewButton'] = $screen->getVar('usedeleteview'); + } else { + $screenButtonText['resetViewButton'] = ""; + $screenButtonText['saveViewButton'] = ""; + $screenButtonText['deleteViewButton'] = ""; + } + } + if($delete_other_reports = $gperm_handler->checkRight("delete_other_reports", $fid, $groups, $mid)) { $pubstart = 10000; } + if($screenButtonText['saveButton']) { $screenButtonText['goButton'] = $screenButtonText['saveButton']; } // want this button accessible by two names, essentially, since it serves two purposes semantically/logically + $onActionButtonCounter = 0; + $atLeastOneActionButton = false; + foreach($screenButtonText as $scrButton=>$scrText) { + formulize_benchmark("before creating button: ".$scrButton); + $buttonCodeArray[$scrButton] = formulize_screenLOEButton($scrButton, $scrText, $settings, $fid, $frid, $colhandles, $flatcols, $pubstart, $loadOnlyView, $calc_cols, $calc_calcs, $calc_blanks, $calc_grouping, $singleMulti[0]['singleentry'], $lastloaded, $currentview, $endstandard, $pickgroups, $viewoptions, $loadviewname, $advcalc_acid, $screen); + formulize_graphScreenLOEButton($scrButton, $scrText, $fid, $frid, $flatcols, $pubstart, $loadOnlyView, $doNotForceSingle, $lastloaded, $currentview, $endstandard, $pickgroups, $viewoptions, $loadviewname, $screen) + formulize_benchmark("button done"); + if($buttonCodeArray[$scrButton] AND $onActionButtonCounter < 14) { // first 14 items in the array should be the action buttons only + $atLeastOneActionButton = true; + } + $onActionButtonCounter++; + } + // TODO: make some kind of cron job clear up or some kind of caches, update graph only when needed! $graphRelativePathPrefix = "modules/formulize/images/graphs/"; // Uses md5 hash of the data points and graph options to shorten filename and handle non alphanumeric chars $graphRelativePath = $graphRelativePathPrefix . md5(SDATA_DB_SALT.var_export($dataPoints, true).var_export($graphOptions, true)).".png"; $myPicture -> render(XOOPS_ROOT_PATH . "/" . $graphRelativePath); echo ""; + + + $useXhr = false; + if($screen) { + if($screen->getVar('dedisplay')) { + $useXhr = true; + } + } + + + interfaceJavascript($fid, $frid, $currentview, $useWorking, $useXhr, $settings['lockedColumns']); // must be called after form is drawn, so that the javascript which clears ventry can operate correctly (clearing is necessary to avoid displaying the form after clicking the Back button on the form and then clicking a button or doing an operation that causes a posting of the controls form). return; } @@ -383,4 +481,586 @@ function initializeZeros($keys) { function echoBR() { echo "
"; } + + +// THIS FUNCTION LOADS A SAVED VIEW +// fid and frid are only used if a report is being asked for by name +function loadReport($id, $fid, $frid) { + global $xoopsDB; + if(is_numeric($id)) { + $thisview = q("SELECT * FROM " . $xoopsDB->prefix("formulize_saved_views") . " WHERE sv_id='$id'"); + } else { + if($frid) { + $formframe = intval($frid); + $mainform = intval($fid); + } else { + $formframe = intval($fid); + $mainform = "''"; + } + $thisview = q("SELECT * FROM " . $xoopsDB->prefix("formulize_saved_views") . " WHERE sv_name='".formulize_escape($id)."' AND sv_formframe = $formframe AND sv_mainform = $mainform"); + } + if(!isset($thisview[0]['sv_currentview'])) { + print "Error: could not load the specified saved view: '".strip_tags(htmlspecialchars($id))."'"; + return false; + } + $to_return[0] = $thisview[0]['sv_currentview']; + $to_return[1] = $thisview[0]['sv_oldcols']; + $to_return[2] = $thisview[0]['sv_asearch']; + $to_return[3] = $thisview[0]['sv_calc_cols']; + $to_return[4] = $thisview[0]['sv_calc_calcs']; + $to_return[5] = $thisview[0]['sv_calc_blanks']; + $to_return[6] = $thisview[0]['sv_calc_grouping']; + $to_return[7] = $thisview[0]['sv_sort']; + $to_return[8] = $thisview[0]['sv_order']; + $to_return[9] = $thisview[0]['sv_hidelist']; + $to_return[10] = $thisview[0]['sv_hidecalc']; + $to_return[11] = $thisview[0]['sv_lockcontrols']; + $to_return[12] = $thisview[0]['sv_quicksearches']; + return $to_return; +} + +// THIS FUNCTION GENERATES HTML FOR ANY BUTTONS THAT ARE REQUESTED +function formulize_graphScreenLOEButton($button, $buttonText, $fid, $frid, $flatcols, $pubstart, $loadOnlyView, $doNotForceSingle, $lastloaded, $currentview, $endstandard, $pickgroups, $viewoptions, $loadviewname, $screen) { + static $importExportCleanupDone = false; + if($buttonText) { + $buttonText = trans($buttonText); + switch ($button) { + case "modifyScreenLink": + return "getVar('sid').">" . $buttonText . ""; + break; + case "addButton": + $addNewParam = $doNotForceSingle ? "" : "'single'"; // force the addNew behaviour to single entry unless this button is being used on a single entry form, in which case we don't need to force anything + return ""; + break; + case "addMultiButton": + return ""; + break; + case "resetViewButton": + return ""; + break; + case "saveViewButton": + return ""; + break; + case "deleteViewButton": + return ""; + break; + case "currentViewList": + $currentViewList = "" . $buttonText . "
\n"; + if(!$loadviewname AND strstr($currentview, ",") AND !$loadOnlyView) { // if we're on a genuine pick-groups view (not a loaded view)...and the load-only-view override is not in place (which eliminates other viewing options besides the loaded view) + $currentViewList .= "
"; + } + return $currentViewList; + break; + } + } elseif($button == "currentViewList") { // must always set a currentview value in POST even if the list is not visible + return "\n"; + } else { + return false; + } +} + + + +// this function includes the javascript necessary make the interface operate properly +// note the mandatory clearing of the ventry value upon loading of the page. Necessary to make the back button work right (otherwise ventry setting is retained from the previous loading of the page and the form is displayed after the next submission of the controls form) +function interfaceJavascript($fid, $frid, $currentview, $useWorking, $useXhr, $lockedColumns) { +?> +"; + print "\n"; + print " + \ No newline at end of file From efb3fa53443760190fd71ffce81c487e9a62008a Mon Sep 17 00:00:00 2001 From: Panji Wisesa Date: Mon, 28 Apr 2014 02:22:21 -0700 Subject: [PATCH 21/40] Added the option to pick default view Still very dirty but filtered data from selected view is now available (has been printed) not yet put into graphDisplay process though --- modules/formulize/admin/formindex.php | 2 +- .../admin/save/screen_graph_cases_save.php | 1 + modules/formulize/admin/screen.php | 24 + modules/formulize/class/graphScreen.php | 8 +- modules/formulize/include/entriesdisplay.php | 17 +- modules/formulize/include/graphdisplay.php | 1085 +++++++---------- modules/formulize/sql/mysql.sql | 1 + .../templates/admin/screen_graph_cases.html | 11 + 8 files changed, 467 insertions(+), 682 deletions(-) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index 528ac2e61..232917e54 100755 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -112,7 +112,7 @@ function patch40() { * ====================================== */ $checkThisTable = 'formulize_screen_graph'; - $checkThisField = 'dataelem'; + $checkThisField = 'defaultview'; $checkThisProperty = false; $checkPropertyForValue = false; diff --git a/modules/formulize/admin/save/screen_graph_cases_save.php b/modules/formulize/admin/save/screen_graph_cases_save.php index e77dc38a9..98384c3d9 100644 --- a/modules/formulize/admin/save/screen_graph_cases_save.php +++ b/modules/formulize/admin/save/screen_graph_cases_save.php @@ -31,6 +31,7 @@ $screen->setVar('ops',$screens['ops']); $screen->setVar('labelelem',$screens['labelelem']); $screen->setVar('dataelem',$screens['dataelem']); +$screen->setVar('defaultview',$screens['defaultview']); if(!$screen_handler->insert($screen)) { diff --git a/modules/formulize/admin/screen.php b/modules/formulize/admin/screen.php index e73677ea9..fd0cb3ce0 100644 --- a/modules/formulize/admin/screen.php +++ b/modules/formulize/admin/screen.php @@ -408,6 +408,30 @@ function multiPageScreen_addToOptionsList($form_id, $options) { $graph_options['labelelem'] = $labelelem->render(); list($dataelem, $selecteddataelem) = createFieldList($screen->getVar('dataelem'), false, false, "screens-dataelem", "Choose one"); $graph_options['dataelem'] = $dataelem->render(); + $framework_handler =& xoops_getmodulehandler('frameworks', 'formulize'); + $form_handler =& xoops_getmodulehandler('forms', 'formulize'); + $formObj = $form_handler->get($form_id, true); // true causes all elements to be included even if they're not visible. + $frameworks = $framework_handler->getFrameworksByForm($form_id); + $views = $formObj->getVar('views'); + $viewPublished = $formObj->getVar('viewPublished'); + $viewNames = $formObj->getVar('viewNames'); + $viewFrids = $formObj->getVar('viewFrids'); + $defaultViewOptions = array(); + $defaultViewOptions['blank'] = _AM_FORMULIZE_SCREEN_LOE_BLANK_DEFAULTVIEW; + $defaultViewOptions['mine'] = _AM_FORMULIZE_SCREEN_LOE_DVMINE; + $defaultViewOptions['group'] = _AM_FORMULIZE_SCREEN_LOE_DVGROUP; + $defaultViewOptions['all'] = _AM_FORMULIZE_SCREEN_LOE_DVALL; + for($i=0;$igetVar('name') . ")"; + } else { + $defaultViewOptions[$views[$i]] .= " (" . _AM_FORMULIZE_SCREEN_LOE_VIEW_ONLY_NO_FRAME . ")"; + } + } + $graph_options['defaultviewoptions'] = $defaultViewOptions; + $graph_options['defaultview'] = $screen->getVar('defaultview'); } // common values should be assigned to all tabs diff --git a/modules/formulize/class/graphScreen.php b/modules/formulize/class/graphScreen.php index 582f35529..60c13baad 100644 --- a/modules/formulize/class/graphScreen.php +++ b/modules/formulize/class/graphScreen.php @@ -23,6 +23,7 @@ function formulizeGraphScreen() { $this->initvar("ops", XOBJ_DTYPE_TXTBOX, NULL, false, 255); $this->initvar("labelelem", XOBJ_DTYPE_INT); $this->initvar("dataelem", XOBJ_DTYPE_INT); + $this->initvar("defaultview", XOBJ_DTYPE_TXTBOX, NULL, false, 20); } } @@ -59,9 +60,9 @@ function insert($screen) { $screen->setVar('dobr', 0); // note: conditions is not written to the DB yet, since we're not gathering that info from the UI if (!$update) { - $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb, ops, labelelem, dataelem) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u, %s, %u, %u)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem')); + $sql = sprintf("INSERT INTO %s (sid, width, height, orientation, bgr, bgg, bgb, barr, barg, barb, ops, labelelem, dataelem, defaultview) VALUES (%u, %u, %u, %s, %u, %u, %u, %u, %u, %u, %s, %u, %u, %s)", $this->db->prefix('formulize_screen_graph'), $screen->getVar('sid'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $this->db->quoteString($screen->getVar('defaultview'))); } else { - $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u, ops = %s, labelelem = %u, dataelem = %u WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $screen->getVar('sid')); + $sql = sprintf("UPDATE %s SET width = %u, height = %u, orientation = %s, bgr = %u, bgg = %u, bgb = %u, barr = %u, barg = %u, barb = %u, ops = %s, labelelem = %u, dataelem = %u, defaultview = %s WHERE sid = %u", $this->db->prefix('formulize_screen_graph'), $screen->getVar('width'), $screen->getVar('height'), $this->db->quoteString($screen->getVar('orientation')), $screen->getVar('bgr'), $screen->getVar('bgg'), $screen->getVar('bgb'), $screen->getVar('barr'), $screen->getVar('barg'), $screen->getVar('barb'), $this->db->quoteString($screen->getVar('ops')), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $this->db->quoteString($screen->getVar('defaultview')), $screen->getVar('sid')); } $result = $this->db->query($sql); if (!$result) { @@ -108,7 +109,8 @@ function render($screen, $entry, $settings = "") { // $settings is used internal "height" => $screen->getVar('height'), "orientation" => $screen->getVar('orientation'), "backgroundcolor" => $bgc, - "barcolor" => $barc + "barcolor" => $barc, + "defaultview" => $screen->getVar('defaultview') ]; include_once XOOPS_ROOT_PATH."/modules/formulize/include/graphdisplay.php"; displayGraph('Bar', $screen->getVar('fid'), $screen->getVar('frid'), $screen->getVar('labelelem'), $screen->getVar('dataelem'), $screen->getVar('ops'), $options); diff --git a/modules/formulize/include/entriesdisplay.php b/modules/formulize/include/entriesdisplay.php index 77393f951..c46709d69 100644 --- a/modules/formulize/include/entriesdisplay.php +++ b/modules/formulize/include/entriesdisplay.php @@ -368,10 +368,13 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, // set flag to indicate whether we let the user's scope setting expand beyond their normal permission level (happens when unlocked published views are in effect) $currentViewCanExpand = false; - + print $_POST['currentview']; + print $_POST['loadreport']; // handling change in view, and loading reports/saved views if necessary if($_POST['loadreport']) { + print "o1"; if(substr($_POST['currentview'], 1, 4) == "old_") { // legacy report + print "i1"; // load old report values and then assign them to the correct $_POST keys in order to present the view $loadedView = $_POST['currentview']; $settings['loadedview'] = $loadedView; @@ -385,6 +388,8 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, list($_POST['currentview'], $_POST['oldcols'], $_POST['asearch'], $_POST['calc_cols'], $_POST['calc_calcs'], $_POST['calc_blanks'], $_POST['calc_grouping'], $_POST['sort'], $_POST['order'], $_POST['hlist'], $_POST['hcalc'], $_POST['lockcontrols']) = loadOldReport(substr($_POST['currentview'], 5), $fid, $view_groupscope); } elseif(is_numeric(substr($_POST['currentview'], 1))) { // saved or published view + print "i2 "; + print $_POST['currentview']; $loadedView = $_POST['currentview']; $settings['loadedview'] = $loadedView; // kill the quicksearches @@ -433,9 +438,11 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, } elseif($_POST['advscope'] AND strstr($_POST['advscope'], ",")) { // looking for comma sort of means that we're checking that a valid advanced scope is being sent - $currentView = $_POST['advscope']; + print "o2"; + $currentView = $_POST['advscope']; } elseif($_POST['currentview']) { // could have been unset by deletion of a view or something else, so we must check to make sure it exists before we override the default that was determined above - if(is_numeric(substr($_POST['currentview'], 1))) { + print "o3"; + if(is_numeric(substr($_POST['currentview'], 1))) { // a saved view was requested as the current view, but we don't want to load the entire thing....this means that we just want to use the view to generate the scope, we don't want to load all settings. So we have to load the view, but discard everything but the view's currentview value // if we were supposed to load the whole thing, loadreport would have been set in post and the above code would have kicked in $loadedViewSettings = loadReport(substr($_POST['currentview'], 1), $fid, $frid); @@ -444,6 +451,7 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, $currentView = $_POST['currentview']; } } elseif($loadview) { + print "o4"; $currentView = $loadview; } @@ -479,7 +487,7 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, } - list($scope, $currentView) = buildScope($currentView, $member_handler, $gperm_handler, $uid, $groups, $fid, $mid, $currentViewCanExpand); + list($scope, $currentView) = buildScope($currentView, $member_handler, $gperm_handler, $uid, $groups, $fid, $mid, $currentViewCanExpand); // generate the available views // pubstart used to indicate to the delete button where the list of published views begins in the current view drop down (since you cannot delete published views) @@ -727,6 +735,7 @@ function displayEntries($formframe, $mainform="", $loadview="", $loadOnlyView=0, // create $data and $wq (writable query) formulize_benchmark("before gathering dataset"); list($data, $wq, $regeneratePageNumbers) = formulize_gatherDataSet($settings, $searches, strip_tags($_POST['sort']), strip_tags($_POST['order']), $frid, $fid, $scope, $screen, $currentURL, intval($_POST['forcequery'])); + print_r($data); formulize_benchmark("after gathering dataset/before generating nav"); $formulize_LOEPageNav = formulize_LOEbuildPageNav($data, $screen, $regeneratePageNumbers); formulize_benchmark("after nav/before interface"); diff --git a/modules/formulize/include/graphdisplay.php b/modules/formulize/include/graphdisplay.php index e0231cfcf..501042850 100644 --- a/modules/formulize/include/graphdisplay.php +++ b/modules/formulize/include/graphdisplay.php @@ -35,7 +35,17 @@ include_once XOOPS_ROOT_PATH . "/modules/formulize/libraries/pChart/class/pDraw.class.php"; include_once XOOPS_ROOT_PATH . "/modules/formulize/libraries/pChart/class/pImage.class.php"; +global $xoopsConfig; +// load the formulize language constants if they haven't been loaded already +if ( file_exists(XOOPS_ROOT_PATH."/modules/formulize/language/".$xoopsConfig['language']."/main.php") ) { + include_once XOOPS_ROOT_PATH."/modules/formulize/language/".$xoopsConfig['language']."/main.php"; +} else { + include_once XOOPS_ROOT_PATH."/modules/formulize/language/english/main.php"; +} + include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php"; +include_once XOOPS_ROOT_PATH . "/modules/formulize/class/usersGroupsPerms.php"; +include_once XOOPS_ROOT_PATH.'/modules/formulize/include/functions.php'; /** * IMPORTANT: Implemented User Cases: @@ -101,6 +111,142 @@ function displayGraph($graphType, $fid, $frid, $labelElement, $dataElement, $ope * parameters have same meaning as displayGraph's parameters */ function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $graphOptions) { + + global $xoopsUser; + + $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0=>XOOPS_GROUP_ANONYMOUS); + $mid = getFormulizeModId(); + $gperm_handler =& xoops_gethandler('groupperm'); + $view_globalscope = $gperm_handler->checkRight("view_globalscope", $fid, $groups, $mid); + $view_groupscope = $gperm_handler->checkRight("view_groupscope", $fid, $groups, $mid); + $uid = $xoopsUser ? $xoopsUser->getVar('uid') : "0"; + $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0=>XOOPS_GROUP_ANONYMOUS); + print $graphOptions['defaultview']; + print $_POST['loadreport']; + + //code below is from entriesDisplay, only 1 part copied below is in use in this situation I think +/* + // handling change in view, and loading reports/saved views if necessary + if($_POST['loadreport']) { + //$_POST['currentview'] replaced by $graphOptions['defaultview']; and there's no "p" at the start only the number + //so no need for substr, however I don't know what this does to legacy support + if(substr($_POST['currentview'], 1, 4) == "old_") { // legacy report + // load old report values and then assign them to the correct $_POST keys in order to present the view + $loadedView = $_POST['currentview']; + $settings['loadedview'] = $loadedView; + // kill the quicksearches + foreach($_POST as $k=>$v) { + if(substr($k, 0, 7) == "search_" AND $v != "") { + unset($_POST[$k]); + } + } + + list($_POST['currentview'], $_POST['oldcols'], $_POST['asearch'], $_POST['calc_cols'], $_POST['calc_calcs'], $_POST['calc_blanks'], $_POST['calc_grouping'], $_POST['sort'], $_POST['order'], $_POST['hlist'], $_POST['hcalc'], $_POST['lockcontrols']) = loadOldReport(substr($_POST['currentview'], 5), $fid, $view_groupscope); + + } elseif(is_numeric(substr($_POST['currentview'], 1))) { // saved or published view + print "in here"; + print $graphOptions['defaultview']; + $loadedView = $_POST['currentview']; + $settings['loadedview'] = $loadedView; + // kill the quicksearches + foreach($_POST as $k=>$v) { + if(substr($k, 0, 7) == "search_" AND $v != "") { + unset($_POST[$k]); + } + } + list($_POST['currentview'], $_POST['oldcols'], $_POST['asearch'], $_POST['calc_cols'], $_POST['calc_calcs'], $_POST['calc_blanks'], $_POST['calc_grouping'], $_POST['sort'], $_POST['order'], $_POST['hlist'], $_POST['hcalc'], $_POST['lockcontrols'], $quicksearches) = loadReport(substr($_POST['currentview'], 1), $fid, $frid); + // explode quicksearches into the search_ values + $allqsearches = explode("&*=%4#", $quicksearches); + $colsforsearches = explode(",", $_POST['oldcols']); + for($i=0;$i