From 8b403b977d80928c4ab8b358fcb3d0252639bf95 Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Fri, 6 Nov 2020 17:36:11 -0700 Subject: [PATCH 01/11] Label Management and Printing Developments - Modification to label profile JSON schema - Fully integrate dynamic label to replace previous web-based label printing. Default JSON is applied if collection label formats are not defined - Move label block processing into set of recursive class functions - Adjustments to Word format to accommodate elevation field output - Added various fields needed for vertebrate collections --- classes/OccurrenceLabel.php | 64 +++++++--- collections/reports/labeldynamic.php | 184 ++++++++++++--------------- collections/reports/labelmanager.php | 1 - collections/reports/labels.php | 5 +- collections/reports/labelsword.php | 4 +- 5 files changed, 132 insertions(+), 126 deletions(-) diff --git a/classes/OccurrenceLabel.php b/classes/OccurrenceLabel.php index 0c4e4ada80..db4bc8b7ba 100644 --- a/classes/OccurrenceLabel.php +++ b/classes/OccurrenceLabel.php @@ -262,14 +262,56 @@ private function setLabelFieldArr(){ 'identificationQualifier'=>'o.identificationqualifier', 'typeStatus'=>'o.typestatus', 'recordedBy'=>'o.recordedby', 'recordNumber'=>'o.recordnumber', 'associatedCollectors'=>'o.associatedcollectors', 'eventDate'=>'DATE_FORMAT(o.eventdate,"%e %M %Y") AS eventdate', 'year'=>'o.year', 'month'=>'o.month', 'day'=>'o.day', 'monthName'=>'DATE_FORMAT(o.eventdate,"%M") AS monthname', 'verbatimEventDate'=>'o.verbatimeventdate', 'habitat'=>'o.habitat', 'substrate'=>'o.substrate', 'occurrenceRemarks'=>'o.occurrenceremarks', 'associatedTaxa'=>'o.associatedtaxa', - 'verbatimAttributes'=>'o.verbatimattributes', 'reproductiveCondition'=>'o.reproductivecondition', 'cultivationStatus'=>'o.cultivationstatus', 'establishmentMeans'=>'o.establishmentmeans', + 'dynamicProperties'=>'o.dynamicproperties','verbatimAttributes'=>'o.verbatimattributes', 'behavior'=>'behavior', 'reproductiveCondition'=>'o.reproductivecondition', 'cultivationStatus'=>'o.cultivationstatus', + 'establishmentMeans'=>'o.establishmentmeans','lifeStage'=>'lifestage','sex'=>'sex','individualCount'=>'individualcount','samplingProtocol'=>'samplingprotocol','preparations'=>'preparations', 'country'=>'o.country', 'stateProvince'=>'o.stateprovince', 'county'=>'o.county', 'municipality'=>'o.municipality', 'locality'=>'o.locality', 'decimalLatitude'=>'o.decimallatitude', 'decimalLongitude'=>'o.decimallongitude', 'geodeticDatum'=>'o.geodeticdatum', 'coordinateUncertaintyInMeters'=>'o.coordinateuncertaintyinmeters', 'verbatimCoordinates'=>'o.verbatimcoordinates', 'elevationInMeters'=>'CONCAT_WS(" - ",o.minimumelevationinmeters,o.maximumelevationinmeters) AS elevationinmeters', 'verbatimElevation'=>'o.verbatimelevation', - 'disposition'=>'o.disposition', 'duplicateQuantity'=>'o.duplicatequantity', 'dateLastModified'=>'o.datelastmodified'); + 'minimumDepthInMeters'=>'minimumdepthinmeters', 'maximumDepthInMeters'=>'maximumdepthinmeters', 'verbatimDepth'=>'verbatimdepth', + 'disposition'=>'o.disposition', 'storageLocation'=>'storagelocation', 'duplicateQuantity'=>'o.duplicatequantity', 'dateLastModified'=>'o.datelastmodified'); } } + public function getLabelBlock($blockArr,$occArr){ + $outStr = ''; + foreach($blockArr as $bArr){ + if(array_key_exists('divElem', $bArr)){ + $outStr .= $this->getDivElem($bArr['divElem'],$occArr); + } + elseif(array_key_exists('fields', $bArr)){ + $delimiter = (isset($bArr['delimiter'])?$bArr['delimiter']:''); + $cnt = 0; + $fieldDivStr = ''; + foreach($bArr['fields'] as $fieldArr){ + $fieldName = $fieldArr['field']; + $fieldValue = trim($occArr[$fieldName]); + if($fieldValue){ + if($delimiter && $cnt) $fieldDivStr .= $delimiter; + if(isset($fieldArr['prefix']) && $fieldArr['prefix']){ + $fieldDivStr .= ''.$fieldArr['prefix'].''; + } + $fieldDivStr .= ''.$fieldValue.''; + if(isset($fieldArr['suffix']) && $fieldArr['suffix']){ + $fieldDivStr .= ''.$fieldArr['suffix'].''; + } + $cnt++; + } + } + if($fieldDivStr) $outStr .= '
'.$fieldDivStr.'
'; + } + } + return $outStr; + } + + private function getDivElem($divArr,$occArr){ + if(array_key_exists('blocks', $divArr)){ + if($blockStr = $this->getLabelBlock($divArr['blocks'],$occArr)){ + return '
'.$blockStr.'
'."\n"; + } + } + return ''; + } + public function getLabelFormatArr($index){ if(is_numeric($index) && $this->collArr['dynprops']){ $dymPropArr = json_decode($this->collArr['dynprops'],true); @@ -460,24 +502,6 @@ public function getErrorArr(){ return $this->errorArr; } - //Misc functions - function parseCSS($fileName){ - global $SERVER_ROOT; - if(!$fileName) $fileName = 'defaultlabels.css'; - $fh = fopen($SERVER_ROOT.'/collections/reports/css/'.$fileName); - $retArr = array(); - preg_match_all('/(.+?)\s?\{\s?(.+?)\s?\}/', $css, $matches); - foreach($matches[0] AS $i => $original){ - foreach(explode(';', $matches[2][$i]) AS $attr){ - if (strlen(trim($attr)) > 0){ - list($name, $value) = explode(':', $attr); - $retArr[$matches[1][$i]][trim($name)] = trim($value); - } - } - } - return $retArr; - } - //Internal cleaning functions private function cleanInStr($str){ $newStr = trim($str); diff --git a/collections/reports/labeldynamic.php b/collections/reports/labeldynamic.php index 96dbad3ea3..162638ddc5 100644 --- a/collections/reports/labeldynamic.php +++ b/collections/reports/labeldynamic.php @@ -14,23 +14,14 @@ $useSymbBarcode = array_key_exists('symbbc',$_POST)?$_POST['symbbc']:0; $barcodeOnly = array_key_exists('bconly',$_POST)?$_POST['bconly']:0; $outputType = array_key_exists('outputtype',$_POST)?$_POST['outputtype']:'html'; - -if($outputType == 'word'){ - header("Content-Type: application/vnd.ms-word; charset=".$CHARSET); - header("Expires: 0"); - header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); - header("content-disposition: attachment;filename=labels.doc"); -} -else{ - header("Content-Type: text/html; charset=".$CHARSET); -} +$action = array_key_exists('submitaction',$_POST)?$_POST['submitaction']:''; //Sanitation $hPrefix = filter_var($hPrefix, FILTER_SANITIZE_STRING); $hMid = filter_var($hMid, FILTER_SANITIZE_STRING); $hSuffix = filter_var($hSuffix, FILTER_SANITIZE_STRING); $lFooter = filter_var($lFooter, FILTER_SANITIZE_STRING); -if(!is_numeric($labelFormatIndex)) $labelFormatIndex = 0; +if(!is_numeric($labelFormatIndex)) $labelFormatIndex = ''; if(!is_numeric($labelFormat) && $labelFormat != 'packet') $labelFormat = 3; if(!is_numeric($showcatalognumbers)) $showcatalognumbers = 0; if(!is_numeric($useBarcode)) $useBarcode = 0; @@ -40,66 +31,83 @@ $labelManager = new OccurrenceLabel(); $labelManager->setCollid($collid); -$labelFormatIndex = 0; -$labelFormatJson = -'{"labelFormats": [ - { - "name":"simple label", - "displaySpeciesAuthor":1, - "displayCatNum":1, - "displayBarcode":1, - "labelFormat":"2", - "defaultStyles":"font-style:time roman;font-size:12px", - "defaultCss":"", - "labelHeader":{ - "hPrefix":"Carex of", - "hMidCol":3, - "hSuffix":"county", - "style":"text-align:center;font-weight:bold;font-size:120%;clear:both;" - }, - "labelFooter":{ - "textValue":"Arizona State University", - "style":"text-align:center;font-weight:bold;font-size:120%;clear:both;" - }, - "blocks":[ - {"fields":[{"field":"family","styles":["float:right"]}]}, - {"divClass":"taxonomyDiv","divStyle":"margin-top:5px","fields":[ - {"field":"identificationqualifier"}, - {"field":"speciesname","fieldStyle":"font-weight:bold;font-style:italic"}, - {"field":"parentauthor"}, - {"field":"taxonrank","fieldStyle":"font-weight:bold"}, - {"field":"infraspecificepithet","fieldStyle":"font-weight:bold;font-style:italic"}, - {"field":"scientificnameauthorship"} - ],"delimiter":" "}, - {"fields":[{"field":"identifiedby","prefix":"Det by: "},{"field":"dateidentified"}]}, - {"fields":[{"field":"identificationreferences"}]}, - {"fields":[{"field":"identificationremarks"}]}, - {"fields":[{"field":"taxonremarks"}]}, - {"divClass":"localDiv","divStyle":"margin-top:10px;","fields":[ - {"field":"country"}, - {"field":"stateprovince"}, - {"field":"county"}, - {"field":"municipality"}, - {"field":"locality"} - ],"delimiter":", "}, - {"fields":[{"field":"verbatimcoordinates"}]}, - {"fields":[{"field":"decimallatitude"},{"field":"decimallongitude","fieldStyle":"margin-left:10px"},{"field":"coordinateuncertaintyinmeters","prefix":"+-","suffix":" meters","fieldStyle":"margin-left:10px"},{"field":"geodeticdatum","prefix":"[","suffix":"]","fieldStyle":"margin-left:10px"}]}, - {"fields":[{"field":"elevationinmeters","prefix":"Elev: ","suffix":"m. "},{"field":"verbatimelevation"}]}, - {"fields":[{"field":"habitat","suffix":"."}]}, - {"fields":[{"field":"substrate","suffix":"."}]}, - {"fields":[{"field":"verbatimattributes"},{"field":"establishmentmeans"}],"delimiter":"; "}, - {"fields":[{"field":"associatedtaxa","prefix":"Associated species: ","fieldStyle":"font-style:italic"}]}, - {"fields":[{"field":"occurrenceremarks"}]}, - {"fields":[{"field":"typestatus"}]}, - {"divClass":"collectorDiv","fields":[{"field":"recordedby","fieldStyle":"float:left"},{"field":"recordnumber","fieldStyle":"float:left;margin-left:10px"},{"field":"eventdate","fieldStyle":"float:right"}]}, - {"fields":[{"field":"associatedcollectors","prefix":"With: ","fieldStyle":"clear:both; margin-left:10px;"}]} - ] - } -]}'; -$labelFormatArr = json_decode($labelFormatJson,true); -$targetLabelFormat = $labelFormatArr['labelFormats'][$labelFormatIndex]; +if($outputType == 'word'){ + header("Content-Type: application/vnd.ms-word; charset=".$CHARSET); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("content-disposition: attachment;filename=labels.doc"); +} +elseif($action == 'Export to CSV'){ + $labelManager->exportLabelCsvFile($_POST); + exit; +} +else{ + header("Content-Type: text/html; charset=".$CHARSET); +} -//$targetLabelFormat = $labelManager->getLabelFormatArr($labelFormatIndex); +$targetLabelFormatArr = $labelManager->getLabelFormatArr($labelFormatIndex); +if(!$targetLabelFormatArr){ + $labelFormatJson = + '{"labelFormats": [ + { + "name":"simple label", + "displaySpeciesAuthor":1, + "displayCatNum":1, + "displayBarcode":1, + "labelFormat":"2", + "defaultStyles":"font-style:time roman;font-size:10pt", + "defaultCss":"", + "labelHeader":{ + "hPrefix":"Carex of", + "hMidCol":3, + "hSuffix":"county", + "style":"text-align:center;margin-bottom:10px;font:bold 14pt arial,sans-serif;clear:both;" + }, + "labelFooter":{ + "textValue":"Arizona State University", + "style":"text-align:center;margin-top:10px;font:bold 10pt arial,sans-serif;clear:both;" + }, + "labelBlocks":[ + {"divElem":{"className":"labelBlockDiv","blocks":[ + {"divElem":{"className":"taxonomyDiv","style":"margin-top:5px;font-size:11pt;","blocks":[ + {"fields":[ + {"field":"identificationqualifier"}, + {"field":"speciesname","style":"font-weight:bold;font-style:italic"}, + {"field":"parentauthor"}, + {"field":"taxonrank","style":"font-weight:bold"}, + {"field":"infraspecificepithet","style":"font-weight:bold;font-style:italic"}, + {"field":"scientificnameauthorship"} + ],"delimiter":" " + }, + {"fields":[{"field":"family","styles":["float:right"]}]} + ]}}, + {"fields":[{"field":"identifiedby","prefix":"Det by: "},{"field":"dateidentified"}]}, + {"fields":[{"field":"identificationreferences"}]}, + {"fields":[{"field":"identificationremarks"}]}, + {"fields":[{"field":"taxonremarks"}]}, + {"divElem":{"className":"localDiv","style":"margin-top:10px;font-size:11pt","blocks":[ + {"fields":[{"field":"country","style":"font-weight:bold"},{"field":"stateprovince","style":"font-weight:bold"},{"field":"county"},{"field":"municipality"},{"field":"locality"}],"delimiter":", "} + ]}}, + {"fields":[{"field":"verbatimcoordinates"}]}, + {"fields":[{"field":"decimallatitude"},{"field":"decimallongitude","style":"margin-left:10px"},{"field":"coordinateuncertaintyinmeters","prefix":"+-","suffix":" meters","style":"margin-left:10px"},{"field":"geodeticdatum","prefix":"[","suffix":"]","style":"margin-left:10px"}]}, + {"fields":[{"field":"elevationinmeters","prefix":"Elev: ","suffix":"m. "},{"field":"verbatimelevation"}]}, + {"fields":[{"field":"habitat","suffix":"."}]}, + {"fields":[{"field":"substrate","suffix":"."}]}, + {"fields":[{"field":"verbatimattributes"},{"field":"establishmentmeans"}],"delimiter":"; "}, + {"fields":[{"field":"associatedtaxa","prefix":"Associated species: ","style":"font-style:italic"}]}, + {"fields":[{"field":"occurrenceremarks"}]}, + {"fields":[{"field":"typestatus"}]}, + {"divElem":{"className":"collectorDiv","style":"margin-top:10px;","blocks":[ + {"fields":[{"field":"recordedby","style":"float:left"},{"field":"recordnumber","style":"float:left;margin-left:10px"},{"field":"eventdate","style":"float:right"}]}, + {"fields":[{"field":"associatedcollectors","prefix":"with: "}],"style":"clear:both; margin-left:10px;"} + ]}} + ]}} + ] + } + ]}'; + $labelFormatArr = json_decode($labelFormatJson,true); + $targetLabelFormatArr = $labelFormatArr['labelFormats'][0]; +} $columnCount = 1; if(is_numeric($labelFormat)) $columnCount = $labelFormat; @@ -116,13 +124,13 @@ <?php echo $DEFAULT_TITLE; ?> Labels @@ -340,27 +341,27 @@ function labelFormatChanged(selObj){ ?>
- Label Printing -
+ Label Printing -
Predefined Label Format:
-
- +
+
Predefined Label Format:
+
+ +
-
Heading Prefix:
@@ -368,7 +369,7 @@ function labelFormatChanged(selObj){
-
Heading Mid-Section:
+
Heading Mid-Section:
Country State @@ -378,60 +379,52 @@ function labelFormatChanged(selObj){
-
Heading Suffix:
-
+ Heading Suffix: + -
+
-
Label Footer:
-
+ Label Footer: + -
+
-
- -
-
Print species authors for infraspecific taxa
+ + Print species authors for infraspecific taxa
-
- -
-
Print Catalog Numbers
+ + Print Catalog Numbers
-
- -
-
Include barcode of Catalog Number
+ + Include barcode of Catalog Number
-
- -
-
Include barcode of Symbiota Identifier
+ + Include barcode of Symbiota Identifier
-
- -
-
Print only Barcode
+ + Print only Barcode
-
- Label Format - 1 columns per page
- 2 columns per page
- 3 columns per page
- packet labels
-
+
+
+ Label Format + 1 columns per page
+ 2 columns per page
+ 3 columns per page
+ packet labels
+
+
From cae8252a857f98e2eb06e26d8dfae0e9ac372262 Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Mon, 9 Nov 2020 22:37:46 -0700 Subject: [PATCH 06/11] Misc Minor Adjustments - Fix identification key editor bug interferring with opening and closing character categories - Taxonomy batch loader kingdom sort order fix --- classes/TaxonomyUpload.php | 2 +- ident/tools/editor.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/TaxonomyUpload.php b/classes/TaxonomyUpload.php index e7207c8c1b..3862ccf477 100644 --- a/classes/TaxonomyUpload.php +++ b/classes/TaxonomyUpload.php @@ -981,7 +981,7 @@ public function getTaxAuthorityName(){ public function getKingdomArr(){ $retArr = array(); - $rs = $this->conn->query('SELECT tid, sciname FROM taxa WHERE rankid = 10'); + $rs = $this->conn->query('SELECT tid, sciname FROM taxa WHERE rankid = 10 ORDER BY sciname'); while($r = $rs->fetch_object()){ $retArr[$r->tid] = $r->sciname; } diff --git a/ident/tools/editor.php b/ident/tools/editor.php index f250267852..32035d5bfd 100644 --- a/ident/tools/editor.php +++ b/ident/tools/editor.php @@ -120,14 +120,15 @@ function openPopup(urlStr,windowName){ echo ''; $count = 0; foreach($cList as $heading => $charArray){ + $headingID = str_replace(array(' ','&'),'_',$heading); if(!$charValue){ echo '
'; echo ''; - echo ' '; - echo ' '; + echo ' '; + echo ' '; echo $heading.''; } - echo '
'; + echo '
'; foreach($charArray as $cidKey => $charNameStr){ if(!$charValue || $charValue == $cidKey){ echo "
"; From 9647e5ce4f7332a72dda410ba63ad66ce18e8474 Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Tue, 10 Nov 2020 16:53:44 -0700 Subject: [PATCH 07/11] Occurrence Label Devlopment continued - Establish framework that will support label profiles defined for portal, collection, and users - Establish a label format configuration file where portal can establish default label formats for a portal. Move sample JSON label definitions into the label config file - Add dynamicProperties field to user table to store user specific label formats - Minor adjustments to Word label code to keep page in sync with current development --- classes/OccurrenceLabel.php | 115 ++++++++++--- classes/WordCloud.php | 38 ++--- collections/editor/dev/occureditor.php | 10 +- collections/reports/labeldynamic.php | 152 +++--------------- collections/reports/labelmanager.php | 60 ++++--- collections/reports/labels.php | 18 +-- collections/reports/labelsword.php | 58 +++---- .../specprocessor/wordcloudhandler.php | 2 +- .../dev/db_schema_patch_pending.sql | 5 +- .../{ => collections}/occureditor/.gitignore | 0 content/collections/reports/.gitignore | 5 + .../{ => collections}/wordclouds/.gitignore | 0 12 files changed, 225 insertions(+), 238 deletions(-) rename content/{ => collections}/occureditor/.gitignore (100%) create mode 100644 content/collections/reports/.gitignore rename content/{ => collections}/wordclouds/.gitignore (100%) diff --git a/classes/OccurrenceLabel.php b/classes/OccurrenceLabel.php index efa846389f..20ca2f2a8a 100644 --- a/classes/OccurrenceLabel.php +++ b/classes/OccurrenceLabel.php @@ -275,14 +275,14 @@ private function setLabelFieldArr(){ public function getLabelBlock($blockArr,$occArr){ $outStr = ''; foreach($blockArr as $bArr){ - if(array_key_exists('divElem', $bArr)){ - $outStr .= $this->getDivElem($bArr['divElem'],$occArr); + if(array_key_exists('divBlock', $bArr)){ + $outStr .= $this->getDivBlock($bArr['divBlock'],$occArr); } - elseif(array_key_exists('fields', $bArr)){ + elseif(array_key_exists('fieldBlock', $bArr)){ $delimiter = (isset($bArr['delimiter'])?$bArr['delimiter']:''); $cnt = 0; $fieldDivStr = ''; - foreach($bArr['fields'] as $fieldArr){ + foreach($bArr['fieldBlock'] as $fieldArr){ $fieldName = $fieldArr['field']; $fieldValue = trim($occArr[$fieldName]); if($fieldValue){ @@ -293,7 +293,7 @@ public function getLabelBlock($blockArr,$occArr){ } $fieldDivStr .= $fieldValue; if(isset($fieldArr['suffix']) && $fieldArr['suffix']){ - $fieldDivStr .= ''.$fieldArr['suffix'].''; + $fieldDivStr .= ''.$fieldArr['suffix'].''; } $fieldDivStr .= ''; $cnt++; @@ -305,7 +305,7 @@ public function getLabelBlock($blockArr,$occArr){ return $outStr; } - private function getDivElem($divArr,$occArr){ + private function getDivBlock($divArr,$occArr){ if(array_key_exists('blocks', $divArr)){ if($blockStr = $this->getLabelBlock($divArr['blocks'],$occArr)){ return '
'.$blockStr.'
'."\n"; @@ -314,30 +314,109 @@ private function getDivElem($divArr,$occArr){ return ''; } - public function getLabelFormatArr($index){ - if(is_numeric($index) && $this->collArr['dynprops']){ - $dymPropArr = json_decode($this->collArr['dynprops'],true); - if(isset($dymPropArr['labelFormats'][$index])){ - return $dymPropArr['labelFormats'][$index]; + public function getLabelFormatArr($labelCat, $labelIndex){ + if(is_numeric($labelIndex)){ + if($labelCat == 'global'){ + if(file_exists($GLOBALS['SERVER_ROOT'].'/content/collections/reports/labeljson.php')){ + include($GLOBALS['SERVER_ROOT'].'/content/collections/reports/labeljson.php'); + if(isset($LABEL_FORMAT_JSON)){ + if($labelFormatArr = json_decode($LABEL_FORMAT_JSON,true)){ + if(isset($labelFormatArr['labelFormats'][$labelIndex])){ + return $labelFormatArr['labelFormats'][$labelIndex]; + } + else $this->errorArr[] = 'ERROR returning global format: index does not exist'; + } + else $this->errorArr[] = 'ERROR returning global format: issue parsing JSON string'; + } + else $this->errorArr[] = 'ERROR returning global format: $LABEL_FORMAT_JSON does not exist'; + } + else $this->errorArr[] = 'ERROR returning global format: /content/collections/reports/labeljson.php does not exist'; + return false; + } + elseif($labelCat == 'coll'){ + if($this->collArr['dynprops']){ + if($dymPropArr = json_decode($this->collArr['dynprops'],true)){ + if(isset($dymPropArr['labelFormats'][$labelIndex])){ + return $dymPropArr['labelFormats'][$labelIndex]; + } + else $this->errorArr[] = 'ERROR returning collection format: labelFormats or index does not exist'; + } + else $this->errorArr[] = 'ERROR returning collection format: issue parsing JSON string'; + } + else $this->errorArr[] = 'ERROR returning collection format: dynamicProperties not defined'; + } + elseif($labelCat == 'user'){ + $dynPropStr = ''; + $sql = 'SELECT dynamicProperties FROM users WHERE uid = '.$GLOBALS['SYMB_UID']; + $rs = $this->conn->query($sql); + if($r = $rs->fetch_object()){ + $dynPropStr = $r->dynamicProperties; + } + $rs->free(); + if($dynPropStr){ + if($dymPropArr = json_decode($dynPropStr,true)){ + if(isset($dymPropArr['labelFormats'][$labelIndex])){ + return $dymPropArr['labelFormats'][$labelIndex]; + } + else $this->errorArr[] = 'ERROR returning user format: labelFormats or index does not exist'; + } + else $this->errorArr[] = 'ERROR returning user format: issue parsing JSON string'; + } + else $this->errorArr[] = 'ERROR returning user format: dynamicProperties not defined'; } } return false; } public function getLabelFormatAnnotatedArr(){ + $labelFormatArr = array(); + //Add global portal defined label formats + if(file_exists($GLOBALS['SERVER_ROOT'].'/content/collections/reports/labeljson.php')){ + include($GLOBALS['SERVER_ROOT'].'/content/collections/reports/labeljson.php'); + if(isset($LABEL_FORMAT_JSON)){ + if($globalFormatArr = json_decode($LABEL_FORMAT_JSON,true)){ + if(isset($globalFormatArr['labelFormats'])){ + foreach($globalFormatArr['labelFormats'] as $k => $labelObj){ + unset($labelObj['labelBlocks']); + $labelFormatArr['g'][$k] = $labelObj; + } + } + } + } + } + //Add collection defined label formats if($this->collArr['dynprops']){ - if($dymPropArr = json_decode($this->collArr['dynprops'],true)){ + if($collFormatArr = json_decode($this->collArr['dynprops'],true)){ + if(isset($collFormatArr['labelFormats'])){ + foreach($collFormatArr['labelFormats'] as $k => $labelObj){ + unset($labelObj['labelBlocks']); + $labelFormatArr['c'][$k] = $labelObj; + } + } + } + } + //Add label formats associated with user profile + /* + $dynPropStr = ''; + $sql = 'SELECT dynamicProperties FROM users WHERE uid = '.$GLOBALS['SYMB_UID']; + $rs = $this->conn->query($sql); + if($r = $rs->fetch_object()){ + $dynPropStr = $r->dynamicProperties; + } + $rs->free(); + if($dynPropStr){ + if($dymPropArr = json_decode($dynPropStr,true)){ if(isset($dymPropArr['labelFormats'])){ - $labelFormatArr = $dymPropArr['labelFormats']; - foreach($labelFormatArr as $k => $labelObj){ - unset($labelFormatArr[$k]['blocks']); + foreach($dymPropArr['labelFormats'] as $k => $labelObj){ + unset($labelObj['labelBlocks']); + $labelFormatArr['u'][$k] = $labelObj; } - if($labelFormatArr) return $labelFormatArr; - else return false; + } } } - return null; + */ + return $labelFormatArr; } //Annotation functions diff --git a/classes/WordCloud.php b/classes/WordCloud.php index fc7320016d..f92e77aa0e 100644 --- a/classes/WordCloud.php +++ b/classes/WordCloud.php @@ -2,14 +2,14 @@ include_once($SERVER_ROOT.'/config/dbconnection.php'); class WordCloud{ - + private $conn; private $frequencyArr = array(); - private $commonWordArr = array(); - + private $commonWordArr = array(); + //custom parameters private $displayedWordCount; - private $tagUrl; + private $tagUrl; private $backgroundImage; private $backgroundColor; private $cloudWidth; @@ -18,11 +18,11 @@ class WordCloud{ public function __construct(){ $this->conn = MySQLiConnectionFactory::getCon("readonly"); - + $this->displayedWordCount = 100; if($GLOBALS['charset'] == 'ISO-8859-1') $this->supportUtf8 = false; $this->tagUrl = "http://www.google.com/search?hl=en&q="; - + $this->backgroundColor = "#000"; $this->wordColors[0] = "#5122CC"; $this->wordColors[1] = "#229926"; @@ -34,7 +34,7 @@ public function __construct(){ $this->wordColors[7] = "#B23B3B"; $this->wordColors[8] = "#229938"; $this->wordColors[9] = "#419922"; - + $commonWordStr = "a,able,about,across,after,all,almost,also,am,among,an,and,any,are,arent," . "as,at,be,because,been,but,by,can,cant,cannot,could,couldve,couldnt,dear,did,didnt,do,does,doesnt," . "dont,either,else,ever,every,for,from,get,got,had,has,hasnt,have,he,her,him,his,how,however," . @@ -55,7 +55,7 @@ public function buildWordFile($collectionId = 0,$csMode = 0){ $sqlFrag = 'FROM omoccurrences o INNER JOIN images i ON o.occid = i.occid '. 'INNER JOIN specprocessorrawlabels r ON i.imgid = r.imgid '; if($csMode){ - $sqlFrag .= 'INNER JOIN omcrowdsourcequeue q ON o.occid = q.occid '; + $sqlFrag .= 'INNER JOIN omcrowdsourcequeue q ON o.occid = q.occid '; } $sqlColl = 'SELECT DISTINCT c.collid, c.collectionname '.$sqlFrag. 'INNER JOIN omcollections c ON c.collid = o.collid '; @@ -87,8 +87,8 @@ public function buildWordFile($collectionId = 0,$csMode = 0){ echo $cloudStr.'

'; //Write word out to text file $wcPath = $GLOBALS['serverRoot']; - if(substr($wcPath,-1) != '/' && substr($wcPath,-1) != "\\") $wcPath .= '/'; - $wcPath .= 'temp/wordclouds/ocrcloud'.$collid.'.html'; + if(substr($wcPath,-1) != '/' && substr($wcPath,-1) != "\\") $wcPath .= '/'; + $wcPath .= 'content/collections/wordclouds/ocrcloud'.$collid.'.html'; if(file_exists($wcPath)){ $wcFH = fopen($wcPath, 'a'); if(!$wcFH = fopen($wcPath, 'a')) { @@ -124,9 +124,9 @@ public function addTagsFromText($seedText){ $seedText = preg_replace('/\s+/',' ',$seedText); $seedText = trim($seedText); - //Remove common words + //Remove common words $wordArr = array_diff(explode(" ", $seedText),$this->commonWordArr); - + foreach ($wordArr as $key => $value){ $this->addTag($value); } @@ -150,24 +150,24 @@ public function getWordCloud(){ if($this->frequencyArr){ arsort($this->frequencyArr); $topTags = array_slice($this->frequencyArr, 0, $this->displayedWordCount); - + /* randomize the order of elements */ uasort($topTags, 'randomSort'); - + $maxCount = max($this->frequencyArr); foreach ($topTags as $tag => $useCount){ $grade = $this->gradeFrequency(($useCount * 100) / $maxCount); $retStr .= (''. ''.$tag.' '); } $retStr .= '

'; } return $retStr; } - + private function gradeFrequency($frequency){ $grade = 0; if ($frequency >= 90) @@ -188,15 +188,15 @@ private function gradeFrequency($frequency){ $grade = 2; else if ($frequency >= 5) $grade = 1; - + return $grade; } - + //Setters and getters public function setDisplayedWordCount($cnt){ $this->displayedWordCount = $cnt; } - + public function setSearchURL($searchURL){ $this->tagUrl = $searchURL; } diff --git a/collections/editor/dev/occureditor.php b/collections/editor/dev/occureditor.php index a433b413e1..616916f944 100644 --- a/collections/editor/dev/occureditor.php +++ b/collections/editor/dev/occureditor.php @@ -3,8 +3,8 @@ header("Content-Type: text/html; charset=".$CHARSET); header('Access-Control-Allow-Origin: http://www.catalogueoflife.org/col/webservice'); -if(!file_exists('../../content/occureditor/occurEditorDefaultConf.php')){ - echo 'ERROR: Portal is not configured properly. Go to directory '.$_SERVER_ROOT.'/content/occureditor/ and rename all file to remove "_template" for the file name. '; +if(!file_exists('../../content/collections/occureditor/occurEditorDefaultConf.php')){ + echo 'ERROR: Portal is not configured properly. Go to directory '.$_SERVER_ROOT.'/content/collections/occureditor/ and rename all file to remove "_template" for the file name. '; echo 'Alternatively, you can also run the setup.sh file located within the config directory'; exit; } @@ -60,7 +60,7 @@ if($collMap && $collMap['colltype'] == 'General Observations') $isGenObs = 1; //Need to set 3 kinds of config vars: 1) default portal settings, collection defined, and user defined - include('../../content/occureditor/occurEditorDefaultConf.php'); + include('../../content/collections/occureditor/occurEditorDefaultConf.php'); $isEditor = 0; //0 = not editor, 1 = admin, 2 = editor, 3 = taxon editor, 4 = crowdsource editor or collection allows public edits @@ -382,9 +382,9 @@ $cssFile){ - echo ''."\n"; + echo ''."\n"; } - if($crowdSourceMode == 1) echo ''."\n"; + if($crowdSourceMode == 1) echo ''."\n"; foreach($JS_ARR as $jsVal){ echo ''; } diff --git a/collections/reports/labeldynamic.php b/collections/reports/labeldynamic.php index a0bc758ded..3806f4b067 100644 --- a/collections/reports/labeldynamic.php +++ b/collections/reports/labeldynamic.php @@ -7,12 +7,15 @@ $hMid = $_POST['lhmid']; $hSuffix = $_POST['lhsuffix']; $lFooter = $_POST['lfooter']; -$labelFormat = $_POST['labelformat']; -$labelFormatIndex = $_POST['labelformatindex']; +$columnCount = $_POST['columncount']; +$labelIndexGlobal = (isset($_POST['labelformatindex-g'])?$_POST['labelformatindex-g']:''); +$labelIndexColl = (isset($_POST['labelformatindex-c'])?$_POST['labelformatindex-c']:''); +$labelIndexUser = (isset($_POST['labelformatindex-u'])?$_POST['labelformatindex-u']:''); $showcatalognumbers = ((array_key_exists('catalognumbers',$_POST) && $_POST['catalognumbers'])?1:0); $useBarcode = array_key_exists('bc',$_POST)?$_POST['bc']:0; $useSymbBarcode = array_key_exists('symbbc',$_POST)?$_POST['symbbc']:0; $barcodeOnly = array_key_exists('bconly',$_POST)?$_POST['bconly']:0; +$includeSpeciesAuthor = ((array_key_exists('speciesauthors',$_POST) && $_POST['speciesauthors'])?1:0); $outputType = array_key_exists('outputtype',$_POST)?$_POST['outputtype']:'html'; $action = array_key_exists('submitaction',$_POST)?$_POST['submitaction']:''; @@ -21,12 +24,15 @@ $hMid = filter_var($hMid, FILTER_SANITIZE_STRING); $hSuffix = filter_var($hSuffix, FILTER_SANITIZE_STRING); $lFooter = filter_var($lFooter, FILTER_SANITIZE_STRING); -if(!is_numeric($labelFormatIndex)) $labelFormatIndex = ''; -if(!is_numeric($labelFormat) && $labelFormat != 'packet') $labelFormat = 3; +if(!is_numeric($labelIndexGlobal)) $labelIndexGlobal = ''; +if(!is_numeric($labelIndexColl)) $labelIndexColl = ''; +if(!is_numeric($labelIndexUser)) $labelIndexUser = ''; +if(!is_numeric($columnCount) && $columnCount != 'packet') $columnCount = 2; if(!is_numeric($showcatalognumbers)) $showcatalognumbers = 0; if(!is_numeric($useBarcode)) $useBarcode = 0; if(!is_numeric($useSymbBarcode)) $useSymbBarcode = 0; if(!is_numeric($barcodeOnly)) $barcodeOnly = 0; +if(!is_numeric($includeSpeciesAuthor)) $includeSpeciesAuthor = 0; $labelManager = new OccurrenceLabel(); $labelManager->setCollid($collid); @@ -45,121 +51,10 @@ header("Content-Type: text/html; charset=".$CHARSET); } -$targetLabelFormatArr = $labelManager->getLabelFormatArr($labelFormatIndex); -if(!$targetLabelFormatArr){ - $labelFormatJson = - '{"labelFormats": [ - { - "name":"Default Herbarium Label", - "displaySpeciesAuthor":1, - "displayCatNum":0, - "displayBarcode":0, - "labelFormat":"1", - "defaultStyles":"font-style:time roman;font-size:10pt", - "defaultCss":"", - "labelHeader":{ - "hPrefix":"Flora of ", - "hMidCol":3, - "hSuffix":" county", - "style":"text-align:center;margin-bottom:10px;font:bold 14pt arial,sans-serif;clear:both;" - }, - "labelFooter":{ - "textValue":"", - "style":"text-align:center;margin-top:10px;font:bold 10pt arial,sans-serif;clear:both;" - }, - "labelBlocks":[ - {"divElem":{"className":"labelBlockDiv","blocks":[ - {"divElem":{"className":"taxonomyDiv","style":"margin-top:5px;font-size:11pt;","blocks":[ - {"fields":[ - {"field":"identificationqualifier"}, - {"field":"speciesname","style":"font-weight:bold;font-style:italic"}, - {"field":"parentauthor"}, - {"field":"taxonrank","style":"font-weight:bold"}, - {"field":"infraspecificepithet","style":"font-weight:bold;font-style:italic"}, - {"field":"scientificnameauthorship"} - ],"delimiter":" " - }, - {"fields":[{"field":"family","styles":["float:right"]}]} - ]}}, - {"fields":[{"field":"identifiedby","prefix":"Det by: "},{"field":"dateidentified"}]}, - {"fields":[{"field":"identificationreferences"}]}, - {"fields":[{"field":"identificationremarks"}]}, - {"fields":[{"field":"taxonremarks"}]}, - {"divElem":{"className":"localDiv","style":"margin-top:10px;font-size:11pt","blocks":[ - {"fields":[{"field":"country","style":"font-weight:bold"},{"field":"stateprovince","style":"font-weight:bold"},{"field":"county"},{"field":"municipality"},{"field":"locality"}],"delimiter":", "} - ]}}, - {"fields":[{"field":"verbatimcoordinates"}]}, - {"fields":[{"field":"decimallatitude"},{"field":"decimallongitude","style":"margin-left:10px"},{"field":"coordinateuncertaintyinmeters","prefix":"+-","suffix":" meters","style":"margin-left:10px"},{"field":"geodeticdatum","prefix":"[","suffix":"]","style":"margin-left:10px"}]}, - {"fields":[{"field":"elevationinmeters","prefix":"Elev: ","suffix":"m. "},{"field":"verbatimelevation"}]}, - {"fields":[{"field":"habitat","suffix":"."}]}, - {"fields":[{"field":"substrate","suffix":"."}]}, - {"fields":[{"field":"verbatimattributes"},{"field":"establishmentmeans"}],"delimiter":"; "}, - {"fields":[{"field":"associatedtaxa","prefix":"Associated species: ","style":"font-style:italic"}]}, - {"fields":[{"field":"occurrenceremarks"}]}, - {"fields":[{"field":"typestatus"}]}, - {"divElem":{"className":"collectorDiv","style":"margin-top:10px;","blocks":[ - {"fields":[{"field":"recordedby","style":"float:left"},{"field":"recordnumber","style":"float:left;margin-left:10px"},{"field":"eventdate","style":"float:right"}]}, - {"fields":[{"field":"associatedcollectors","prefix":"with: "}],"style":"clear:both; margin-left:10px;"} - ]}} - ]}} - ] - }, - { - "name":"Bird Dry Specimen", - "displaySpeciesAuthor":0, - "displayCatNum":0, - "displayBarcode":0, - "labelFormat":"2", - "defaultStyles":"font-style:time roman;font-size:8pt", - "defaultCss":"", - "labelHeader":{ - "hPrefix":"Arizona State University Ornithology Collection", - "hMidCol":0, - "hSuffix":"", - "style":"text-align:center;margin-bottom:5px;font:bold 7pt arial,sans-serif;clear:both;" - }, - "labelFooter":{ - "textValue":"", - "style":"text-align:center;margin-top:10px;font:bold 10pt arial,sans-serif;clear:both;" - }, - "labelBlocks":[ - {"divElem":{"className":"labelBlockDiv","blocks":[ - {"fields":[{"field":"family","styles":["margin-bottom:2px;font-size:pt"]}]}, - {"divElem":{"className":"taxonomyDiv","style":"font-size:10pt;","blocks":[ - {"fields":[ - {"field":"identificationqualifier"}, - {"field":"speciesname","style":"font-weight:bold;font-style:italic"}, - {"field":"parentauthor"}, - {"field":"taxonrank","style":"font-weight:bold"}, - {"field":"infraspecificepithet","style":"font-weight:bold;font-style:italic"}, - {"field":"scientificnameauthorship"} - ],"delimiter":" " - } - ]}}, - {"fields":[{"field":"identifiedby","prefix":"Det by: "},{"field":"dateidentified"}]}, - {"fields":[{"field":"identificationreferences"}]}, - {"fields":[{"field":"identificationremarks"}]}, - {"fields":[{"field":"taxonremarks"}]}, - {"fields":[{"field":"catalognumber","style":"font-weight:bold;font-size:14pt;margin:5pt 0pt;"}]}, - {"divElem":{"className":"localDiv","style":"margin-top:3px;padding-top:3px;border-top:3px solid black","blocks":[ - {"fields":[{"field":"country"},{"field":"stateprovince","prefix":", "},{"field":"county","prefix":", "},{"field":"municipality","prefix":", "},{"field":"locality","prefix":": "},{"field":"decimallatitude","prefix":": ","suffix":"° N"},{"field":"decimallongitude","prefix":" ","suffix":"° W"},{"field":"coordinateuncertaintyinmeters","prefix":" +-","suffix":" meters","style":"margin-left:10px"},{"field":"elevationinmeters","prefix":", ","suffix":"m."}]} - ]}}, - {"divElem":{"className":"collectorDiv","style":"margin-top:10px;font-size:6pt;clear:both;","blocks":[ - {"fields":[{"field":"recordedby","style":"float:left;","prefix":"Coll.: "},{"field":"preparations","style":"float:right","prefix":"Prep.: "}]} - ]}}, - {"divElem":{"className":"collectorDiv","style":"margin-top:10px;font-size:6pt;clear:both;","blocks":[ - {"fields":[{"field":"recordnumber","style":"float:left;","prefix":"Coll. No: "},{"field":"eventdate","style":"float:right","prefix":"Date: "}]} - ]}} - ]}} - ] - } - ]}'; - $labelFormatArr = json_decode($labelFormatJson,true); - $targetLabelFormatArr = $labelFormatArr['labelFormats'][0]; -} - -$columnCount = 1; -if(is_numeric($labelFormat)) $columnCount = $labelFormat; +$targetLabelFormatArr = false; +if(is_numeric($labelIndexGlobal)) $targetLabelFormatArr = $labelManager->getLabelFormatArr('global',$labelIndexGlobal); +elseif(is_numeric($labelIndexColl)) $targetLabelFormatArr = $labelManager->getLabelFormatArr('coll',$labelIndexGlobal); +elseif(is_numeric($labelIndexUser)) $targetLabelFormatArr = $labelManager->getLabelFormatArr('user',$labelIndexGlobal); $isEditor = 0; if($SYMB_UID){ @@ -177,12 +72,7 @@ ?> .labelDiv { float:left; page-break-before:auto; page-break-inside:avoid; } - .labelDiv { width:%;padding:10px; } - .foldMarks1 { clear:both;padding-top:285px; } .foldMarks1 span { margin-left:77px; margin-right:80px; } @@ -206,6 +96,11 @@ .family { display:none } + .labelDiv { width:%;padding:10px; } + .cnBarcodeDiv { clear:both; padding-top:15px; } .catalogNumber { clear:both; text-align:center; } @@ -217,7 +112,6 @@
getLabelArray($_POST['occid'], $includeSpeciesAuthor); $labelCnt = 0; $rowCnt = 0; @@ -251,11 +145,11 @@ $dupCnt = $_POST['q-'.$occid]; for($i = 0;$i < $dupCnt;$i++){ $labelCnt++; - if($labelFormat == 'packet'){ + if($columnCount == 'packet'){ echo '
++
'; echo '
++
'; } - if($labelCnt%$columnCount == 1){ + elseif($labelCnt%$columnCount == 1){ if($labelCnt > 1) echo '
'; echo '
'; $rowCnt++; @@ -323,7 +217,7 @@ } else{ echo '
'; - if($labelFormatArr) echo 'ERROR: Unable to parse JSON that defines the label format profile '; + if($targetLabelFormatArr) echo 'ERROR: Unable to parse JSON that defines the label format profile '; else 'ERROR: Permissions issue'; echo '
'; } diff --git a/collections/reports/labelmanager.php b/collections/reports/labelmanager.php index 712489a315..74c274b629 100644 --- a/collections/reports/labelmanager.php +++ b/collections/reports/labelmanager.php @@ -133,26 +133,29 @@ function checkBarcodeCheck(f){ } } - function labelFormatChanged(selObj){ + function labelFormatChanged(selObj,catStr){ if(selObj && labelFormatObj){ var labelIndex = selObj.value; var f = document.selectform; - f.lhprefix.value = labelFormatObj[labelIndex].labelHeader.hPrefix; - var midIndex = labelFormatObj[labelIndex].labelHeader.hMidCol; + f.lhprefix.value = labelFormatObj[catStr][labelIndex].labelHeader.hPrefix; + var midIndex = labelFormatObj[catStr][labelIndex].labelHeader.hMidCol; document.getElementById("lhmid"+midIndex).checked = true; - f.lhsuffix.value = labelFormatObj[labelIndex].labelHeader.hSuffix; - f.lfooter.value = labelFormatObj[labelIndex].labelFooter.textValue; - if(labelFormatObj[labelIndex].displaySpeciesAuthor == 1) f.speciesauthors.checked = true; + f.lhsuffix.value = labelFormatObj[catStr][labelIndex].labelHeader.hSuffix; + f.lfooter.value = labelFormatObj[catStr][labelIndex].labelFooter.textValue; + if(labelFormatObj[catStr][labelIndex].displaySpeciesAuthor == 1) f.speciesauthors.checked = true; else f.speciesauthors.checked = false; if(f.bc){ - if(labelFormatObj[labelIndex].displayBarcode == 1) f.bc.checked = true; + if(labelFormatObj[catStr][labelIndex].displayBarcode == 1) f.bc.checked = true; else f.bc.checked = false; } - if(labelFormatObj[labelIndex].displayCatNum == 1) f.catalognumbers.checked = true; + if(labelFormatObj[catStr][labelIndex].displayCatNum == 1) f.catalognumbers.checked = true; else f.catalognumbers.checked = true; - var labelFormatIndex = labelFormatObj[labelIndex].labelFormat; - document.getElementById("labelformat"+labelFormatIndex).checked = true; + var columnCountIndex = labelFormatObj[catStr][labelIndex].columnCount; + if(document.getElementById("columncount"+columnCountIndex)) document.getElementById("columncount"+columnCountIndex).checked = true; + if(catStr != 'g' && f["labelformatindex-g"]) f["labelformatindex-g"].value = ""; + if(catStr != 'c' && f["labelformatindex-c"]) f["labelformatindex-c"].value = ""; + if(catStr != 'u' && f["labelformatindex-u"]) f["labelformatindex-u"].value = ""; } } @@ -348,15 +351,26 @@ function labelFormatChanged(selObj){
Predefined Label Format:
- +
+ +
+
-
+
Label Format - 1 columns per page
- 2 columns per page
- 3 columns per page
- packet labels
+ 1 columns per page
+ 2 columns per page
+ 3 columns per page
+ packet labels
diff --git a/collections/reports/labels.php b/collections/reports/labels.php index 3f3d8deaed..a7d886c48e 100644 --- a/collections/reports/labels.php +++ b/collections/reports/labels.php @@ -8,7 +8,8 @@ $hMid = $_POST['lhmid']; $hSuffix = $_POST['lhsuffix']; $lFooter = $_POST['lfooter']; -$labelFormat = $_POST['labelformat']; +$columnCount = $_POST['columncount']; +$includeSpeciesAuthor = ((array_key_exists('speciesauthors',$_POST) && $_POST['speciesauthors'])?1:0); $showcatalognumbers = ((array_key_exists('catalognumbers',$_POST) && $_POST['catalognumbers'])?1:0); $useBarcode = array_key_exists('bc',$_POST)?$_POST['bc']:0; $useSymbBarcode = array_key_exists('symbbc',$_POST)?$_POST['symbbc']:0; @@ -19,7 +20,8 @@ $hMid = filter_var($hMid, FILTER_SANITIZE_STRING); $hSuffix = filter_var($hSuffix, FILTER_SANITIZE_STRING); $lFooter = filter_var($lFooter, FILTER_SANITIZE_STRING); -if(!is_numeric($labelFormat) && $labelFormat != 'packet') $labelFormat = 3; +if(!is_numeric($columnCount) && $columnCount != 'packet') $columnCount = 2; +if(!is_numeric($includeSpeciesAuthor)) $includeSpeciesAuthor = 0; if(!is_numeric($showcatalognumbers)) $showcatalognumbers = 0; if(!is_numeric($useBarcode)) $useBarcode = 0; if(!is_numeric($useSymbBarcode)) $useSymbBarcode = 0; @@ -28,9 +30,6 @@ $labelManager = new OccurrenceLabel(); $labelManager->setCollid($collid); -$columnCount = 1; -if(is_numeric($labelFormat)) $columnCount = $labelFormat; - $isEditor = 0; if($SYMB_UID){ if($IS_ADMIN) $isEditor = 1; @@ -76,7 +75,7 @@ .cnbarcode { width:100%; text-align:center; } .symbbarcode { width:100%; text-align:center; margin-top:10px; } .foldMarks1 { clear:both;padding-top:285px; } .foldMarks1 span { margin-left:77px; margin-right:80px; } @@ -102,7 +101,6 @@
getLabelArray($_POST['occid'], $includeSpeciesAuthor); $totalLabelCnt = count($labelArr); $labelCnt = 0; @@ -125,11 +123,11 @@ $dupCnt = $_POST['q-'.$occid]; for($i = 0;$i < $dupCnt;$i++){ $labelCnt++; - if($labelFormat == 'packet'){ + if($columnCount == 'packet'){ echo '
++
'; echo '
++
'; } - if($labelCnt%$columnCount == 1){ + elseif($labelCnt%$columnCount == 1){ if($labelCnt > 1) echo ''; echo ''; $rowCnt++; @@ -375,7 +373,7 @@ } } //Add missing '; diff --git a/collections/reports/labelsword.php b/collections/reports/labelsword.php index fc8842792f..d2aa96a826 100644 --- a/collections/reports/labelsword.php +++ b/collections/reports/labelsword.php @@ -10,12 +10,9 @@ $ses_id = time(); -if(class_exists('Image_Barcode2')){ - $bcObj = new Image_Barcode2; -} -elseif(class_exists('Image_Barcode')){ - $bcObj = new Image_Barcode; -} +$bcObj = null; +if(class_exists('Image_Barcode2')) $bcObj = new Image_Barcode2; +elseif(class_exists('Image_Barcode')) $bcObj = new Image_Barcode; $labelManager = new OccurrenceLabel(); @@ -24,37 +21,43 @@ $hMid = $_POST['lhmid']; $hSuffix = $_POST['lhsuffix']; $lFooter = $_POST['lfooter']; -$occIdArr = $_POST['occid']; -$labelFormat = $_POST['labelformat']; -$speciesAuthors = ((array_key_exists('speciesauthors',$_POST) && $_POST['speciesauthors'])?1:0); +$columnCount = $_POST['columncount']; +$includeSpeciesAuthor = ((array_key_exists('speciesauthors',$_POST) && $_POST['speciesauthors'])?1:0); $showcatalognumbers = ((array_key_exists('catalognumbers',$_POST) && $_POST['catalognumbers'])?1:0); $useBarcode = array_key_exists('bc',$_POST)?$_POST['bc']:0; $useSymbBarcode = array_key_exists('symbbc',$_POST)?$_POST['symbbc']:0; $barcodeOnly = array_key_exists('bconly',$_POST)?$_POST['bconly']:0; $action = array_key_exists('submitaction',$_POST)?$_POST['submitaction']:''; -$rowsPerPage = 1; -if(is_numeric($labelFormat)){ - $rowsPerPage = $labelFormat; -} +//Sanitation +$hPrefix = filter_var($hPrefix, FILTER_SANITIZE_STRING); +$hMid = filter_var($hMid, FILTER_SANITIZE_STRING); +$hSuffix = filter_var($hSuffix, FILTER_SANITIZE_STRING); +$lFooter = filter_var($lFooter, FILTER_SANITIZE_STRING); +if(!is_numeric($columnCount) && $columnCount != 'packet') $columnCount = 2; +if(!is_numeric($includeSpeciesAuthor)) $includeSpeciesAuthor = 0; +if(!is_numeric($showcatalognumbers)) $showcatalognumbers = 0; +if(!is_numeric($useBarcode)) $useBarcode = 0; +if(!is_numeric($useSymbBarcode)) $useSymbBarcode = 0; +if(!is_numeric($barcodeOnly)) $barcodeOnly = 0; $sectionStyle = array('pageSizeW'=>12240,'pageSizeH'=>15840,'marginLeft'=>360,'marginRight'=>360,'marginTop'=>360,'marginBottom'=>360,'headerHeight'=>0,'footerHeight'=>0); -if($labelFormat == 1){ +if($columnCount == 1){ $lineWidth = 740; } -elseif($labelFormat == 2){ +elseif($columnCount == 2){ $lineWidth = 350; $sectionStyle['colsNum'] = 2; $sectionStyle['colsSpace'] = 690; $sectionStyle['breakType'] = 'continuous'; } -elseif($labelFormat == 3){ +elseif($columnCount == 3){ $lineWidth = 220; $sectionStyle['colsNum'] = 3; $sectionStyle['colsSpace'] = 690; $sectionStyle['breakType'] = 'continuous'; } -elseif($labelFormat == 'packet'){ +elseif($columnCount == 'packet'){ //$lineWidth = 540; } @@ -101,10 +104,10 @@ $section = $phpWord->addSection($sectionStyle); - $labelArr = $labelManager->getLabelArray($_POST['occid'], $speciesAuthors); + $labelArr = $labelManager->getLabelArray($_POST['occid'], $includeSpeciesAuthor); foreach($labelArr as $occid => $occArr){ - if($labelFormat == 'packet'){ + if($columnCount == 'packet'){ $textrun = $section->addTextRun('foldMarks1'); $textrun->addText('++','foldMarksFont'); $textrun = $section->addTextRun('foldMarks2'); @@ -114,7 +117,6 @@ $table->addRow(); $table->addCell(1750)->addText("+"); $table->addCell(1750)->addText("+"); - } if($barcodeOnly){ @@ -128,18 +130,10 @@ } else{ $midStr = ''; - if($hMid == 1){ - $midStr = $occArr['country']; - } - elseif($hMid == 2){ - $midStr = $occArr['stateprovince']; - } - elseif($hMid == 3){ - $midStr = $occArr['county']; - } - elseif($hMid == 4){ - $midStr = $occArr['family']; - } + if($hMid == 1) $midStr = $occArr['country']; + elseif($hMid == 2) $midStr = $occArr['stateprovince']; + elseif($hMid == 3) $midStr = $occArr['county']; + elseif($hMid == 4) $midStr = $occArr['family']; $headerStr = ''; if($hPrefix || $midStr || $hSuffix){ $headerStrArr = array(); diff --git a/collections/specprocessor/wordcloudhandler.php b/collections/specprocessor/wordcloudhandler.php index 503abc62bf..055e661829 100644 --- a/collections/specprocessor/wordcloudhandler.php +++ b/collections/specprocessor/wordcloudhandler.php @@ -34,7 +34,7 @@ Cloud'.$collTarget.''; ?> diff --git a/config/schema-1.0/dev/db_schema_patch_pending.sql b/config/schema-1.0/dev/db_schema_patch_pending.sql index 9b9a416144..b4d8ac78b0 100644 --- a/config/schema-1.0/dev/db_schema_patch_pending.sql +++ b/config/schema-1.0/dev/db_schema_patch_pending.sql @@ -263,7 +263,10 @@ DROP TABLE `omcollectioncontacts`; ALTER TABLE `omcollcategories` ADD COLUMN `sortsequence` INT NULL AFTER `notes`; - + +ALTER TABLE `users` + ADD COLUMN `dynamicProperties` TEXT NULL AFTER `usergroups`; + ALTER TABLE `userroles` ADD UNIQUE INDEX `Unique_userroles` (`uid` ASC, `role` ASC, `tablename` ASC, `tablepk` ASC); diff --git a/content/occureditor/.gitignore b/content/collections/occureditor/.gitignore similarity index 100% rename from content/occureditor/.gitignore rename to content/collections/occureditor/.gitignore diff --git a/content/collections/reports/.gitignore b/content/collections/reports/.gitignore new file mode 100644 index 0000000000..2698343c36 --- /dev/null +++ b/content/collections/reports/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* +# Except this file and labeljson_template.php +!.gitignore +!.labeljson_template.php diff --git a/content/wordclouds/.gitignore b/content/collections/wordclouds/.gitignore similarity index 100% rename from content/wordclouds/.gitignore rename to content/collections/wordclouds/.gitignore From 2bd835db6f86dfeecea2b4b8aebaf8d21dede424 Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Tue, 10 Nov 2020 17:26:01 -0700 Subject: [PATCH 08/11] Occurrence Label Development - Added import of defaultCss variable into dynamiclabel head --- collections/reports/labeldynamic.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/collections/reports/labeldynamic.php b/collections/reports/labeldynamic.php index 3806f4b067..9797dacae2 100644 --- a/collections/reports/labeldynamic.php +++ b/collections/reports/labeldynamic.php @@ -107,6 +107,12 @@ .otherCatalogNumbers { clear:both; text-align:center; } .symbBarcode { padding-top:10px; } + '; + } + ?>
From 5918911bd970a0fe8e4ecb7cb541faefde51761e Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Tue, 10 Nov 2020 17:52:32 -0700 Subject: [PATCH 09/11] Occurrence Label Development - Adjustment to internal .gitignore so that global label format JSON file is included --- content/collections/reports/.gitignore | 2 +- .../reports/labeljson_template.php | 109 ++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 content/collections/reports/labeljson_template.php diff --git a/content/collections/reports/.gitignore b/content/collections/reports/.gitignore index 2698343c36..837411ffc0 100644 --- a/content/collections/reports/.gitignore +++ b/content/collections/reports/.gitignore @@ -2,4 +2,4 @@ * # Except this file and labeljson_template.php !.gitignore -!.labeljson_template.php +!labeljson_template.php diff --git a/content/collections/reports/labeljson_template.php b/content/collections/reports/labeljson_template.php new file mode 100644 index 0000000000..edc5e7a887 --- /dev/null +++ b/content/collections/reports/labeljson_template.php @@ -0,0 +1,109 @@ + \ No newline at end of file From 947e7d67fe52b21037c19cbe309758a4adc3167c Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Wed, 11 Nov 2020 12:10:07 -0700 Subject: [PATCH 10/11] Occurrence Label Print Module dev - Minor adjustments --- collections/reports/labelmanager.php | 4 ++-- content/collections/reports/labeljson_template.php | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/collections/reports/labelmanager.php b/collections/reports/labelmanager.php index 74c274b629..4e79c73d28 100644 --- a/collections/reports/labelmanager.php +++ b/collections/reports/labelmanager.php @@ -149,8 +149,6 @@ function labelFormatChanged(selObj,catStr){ if(labelFormatObj[catStr][labelIndex].displayBarcode == 1) f.bc.checked = true; else f.bc.checked = false; } - if(labelFormatObj[catStr][labelIndex].displayCatNum == 1) f.catalognumbers.checked = true; - else f.catalognumbers.checked = true; var columnCountIndex = labelFormatObj[catStr][labelIndex].columnCount; if(document.getElementById("columncount"+columnCountIndex)) document.getElementById("columncount"+columnCountIndex).checked = true; if(catStr != 'g' && f["labelformatindex-g"]) f["labelformatindex-g"].value = ""; @@ -419,10 +417,12 @@ function labelFormatChanged(selObj,catStr){ Include barcode of Catalog Number
+
Print only Barcode diff --git a/content/collections/reports/labeljson_template.php b/content/collections/reports/labeljson_template.php index edc5e7a887..005ee427e7 100644 --- a/content/collections/reports/labeljson_template.php +++ b/content/collections/reports/labeljson_template.php @@ -4,7 +4,6 @@ { "name":"Generic Herbarium Label", "displaySpeciesAuthor":1, - "displayCatNum":0, "displayBarcode":0, "columnCount":"2", "defaultStyles":"font-style:time roman;font-size:10pt", @@ -59,7 +58,6 @@ { "name":"Generic Vertebrate Label", "displaySpeciesAuthor":0, - "displayCatNum":0, "displayBarcode":0, "columnCount":"3", "defaultStyles":"font-style:time roman;font-size:8pt", From 0caab58f3e92881de5b0454a2ecc84d8232d84f9 Mon Sep 17 00:00:00 2001 From: Edward Gilbert Date: Wed, 11 Nov 2020 13:18:48 -0700 Subject: [PATCH 11/11] Occurrence Label debugging continued --- collections/reports/labelmanager.php | 98 ++++++++++++++++------------ 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/collections/reports/labelmanager.php b/collections/reports/labelmanager.php index 4e79c73d28..e670a842ce 100644 --- a/collections/reports/labelmanager.php +++ b/collections/reports/labelmanager.php @@ -106,9 +106,19 @@ function openPopup(urlStr){ return false; } - function changeFormExport(action,target){ - var f = document.selectform; - if(action == "labelsword.php" && document.getElementById('packetradio').checked == true){ + function changeFormExport(buttonElem, action, target){ + var f = buttonElem.form; + if(action == "labeldynamic.php" && buttonElem.value == "Print in Browser"){ + labelFormatSelected = false; + if(f["labelformatindex-g"] && f["labelformatindex-g"].value != "") labelFormatSelected = true; + if(f["labelformatindex-c"] && f["labelformatindex-c"].value != "") labelFormatSelected = true; + if(f["labelformatindex-u"] && f["labelformatindex-u"].value != "") labelFormatSelected = true; + if(!labelFormatSelected){ + alert("Please select a Label Format Profile"); + return false; + } + } + else if(action == "labelsword.php" && f.packetradio.checked == true){ alert("Packet labels are not yet available as a Word document"); return false; } @@ -343,37 +353,31 @@ function labelFormatChanged(selObj,catStr){
tags and close the table - if($labelCnt%$columnCount){ + if(is_numeric($columnCount) && $labelCnt%$columnCount){ $remaining = $columnCount-$labelCnt%$columnCount; for($i = 0;$i < $remaining;$i++){ echo ' 
Label Printing - -
-
Predefined Label Format:
-
- $catArr){ - $catStr = 'Portal defined profiles'; - if($cat == 'c') $catStr = 'Collection defined profiles'; - if($cat == 'u') $catStr = 'User defined profiles'; - ?> -
- -
- +
Label Format Profiles:
+
+ $catArr){ + $catStr = 'Portal defined profiles'; + if($cat == 'c') $catStr = 'Collection defined profiles'; + if($cat == 'u') $catStr = 'User defined profiles'; ?> -
+
+ +
+
- +
Heading Prefix:
@@ -387,7 +391,7 @@ function labelFormatChanged(selObj,catStr){ State County Family - Blank + Blank
@@ -432,27 +436,41 @@ function labelFormatChanged(selObj,catStr){ ?>
- Label Format + Column Count 1 columns per page
- 2 columns per page
+ 2 columns per page
3 columns per page
packet labels
- -

- +
+ /> +
+
+ +
-

- +
+ +
+ +
+ Note: Output of variable Label Formats as a Word document is not yet supported
A possible work around is to print labels as PDF and + then convert to a Word doc using Adobe tools.
Another alternatively, is to output the data as CSV and then setup a Mail Merge Word document. +
+