From 00bcf15e0ace7a2277eaa362be3dd091fe5715e5 Mon Sep 17 00:00:00 2001 From: Ben Keen Date: Sat, 29 Jul 2017 20:16:20 -0700 Subject: [PATCH] 3.2.7; closes #428 --- README.md | 4 + api_example.php | 59 +++++++++++ package.json | 2 +- .../dataTypes/Composite/Composite.class.php | 2 +- plugins/dataTypes/Computed/Computed.class.php | 99 +++++++++++++++++++ plugins/dataTypes/Computed/Computed.js | 65 ++++++++++++ plugins/dataTypes/Computed/README.md | 31 ++++++ plugins/dataTypes/Computed/lang/de.php | 18 ++++ plugins/dataTypes/Computed/lang/en.php | 18 ++++ plugins/dataTypes/Computed/lang/es.php | 18 ++++ plugins/dataTypes/Computed/lang/fr.php | 18 ++++ plugins/dataTypes/Computed/lang/nl.php | 18 ++++ plugins/dataTypes/Names/Names.class.php | 79 +++++++++------ .../NamesRegional/NamesRegional.class.php | 4 - plugins/dataTypes/PersonalNumber/lang/en.php | 2 +- plugins/dataTypes/Region/Region.class.php | 2 +- plugins/dataTypes/Rut/Rut.class.php | 53 +++------- resources/classes/Core.class.php | 4 +- 18 files changed, 419 insertions(+), 77 deletions(-) create mode 100644 plugins/dataTypes/Computed/Computed.class.php create mode 100755 plugins/dataTypes/Computed/Computed.js create mode 100644 plugins/dataTypes/Computed/README.md create mode 100644 plugins/dataTypes/Computed/lang/de.php create mode 100644 plugins/dataTypes/Computed/lang/en.php create mode 100644 plugins/dataTypes/Computed/lang/es.php create mode 100644 plugins/dataTypes/Computed/lang/fr.php create mode 100644 plugins/dataTypes/Computed/lang/nl.php diff --git a/README.md b/README.md index fa055c64b..8ee12c44b 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,10 @@ In addition to the many fine folk who submit bug reports, a big thanks to the fo ## Changelog +3.2.7 - Jul 29, 2017 +- "Computed" Data Type added. +- misc bug fixes + 3.2.6 - Apr 17, 2017 - misc bug fixes: https://github.com/benkeen/generatedata/milestone/20?closed=1 diff --git a/api_example.php b/api_example.php index e69de29bb..6e1346be2 100644 --- a/api_example.php +++ b/api_example.php @@ -0,0 +1,59 @@ +smarty = new SecureSmarty(); + $this->smarty->template_dir = realpath(__DIR__ . "/../../../resources/libs/smarty"); + $this->smarty->compile_dir = realpath(__DIR__ . "/../../../cache"); + } + } + + public function generate($generator, $generationContextData) { + foreach ($generationContextData["existingRowData"] as $row) { + $colNum = $row["colNum"]; + $rowInfo = array( + "OPTIONS" => $row["generationOptions"], + "COL_METADATA" => $row["columnMetadata"], + "DATA" => $row["randomData"] + ); + $debug = json_encode($rowInfo); + $rowInfo["DEBUG"] = $debug; + + $this->smarty->assign("ROW{$colNum}", $rowInfo); + } + + return array( + "display" => $this->smarty->fetch('string:' . $generationContextData["generationOptions"]) + ); + } + + public function getRowGenerationOptionsUI($generator, $postdata, $col, $num_cols) { + if (!isset($postdata["dtOption_$col"]) || empty($postdata["dtOption_$col"])) { + return false; + } + return $postdata["dtOption_$col"]; + } + + public function getRowGenerationOptionsAPI($generator, $json, $numCols) { + if (empty($json->settings->placeholder)) { + return false; + } + return $json->settings->placeholder; + } + + public function getExampleColumnHTML() { + $L = Core::$language->getCurrentLanguageStrings(); + return $L["see_help_dialog"]; + } + + public function getOptionsColumnHTML() { + return ''; + } + + public function getHelpHTML() { + $content =<< + {$this->L["help_para1"]} +

+ +

+ {$this->L["help_para2"]} +

+ + + + {$this->L["example"]} + + + +EOF; + + return $content; + } +} diff --git a/plugins/dataTypes/Computed/Computed.js b/plugins/dataTypes/Computed/Computed.js new file mode 100755 index 000000000..1af953ebe --- /dev/null +++ b/plugins/dataTypes/Computed/Computed.js @@ -0,0 +1,65 @@ +/*global $:false*/ +define([ + "manager", + "constants", + "lang", + "generator" +], function(manager, C, L, generator) { + + "use strict"; + + /** + * @name Computed + * @description JS code for the Computed Data Type. + * @see DataType + * @namespace + */ + + /* @private */ + var MODULE_ID = "data-type-Computed"; + var LANG = L.dataTypePlugins.Computed; + + var _validate = function(rows) { + var visibleProblemRows = []; + var problemFields = []; + for (var i=0; i" + visibleProblemRows.join(", ") + ""}); + } + + return errors; + }; + + var _loadRow = function(rowNum, data) { + return { + execute: function() { + $("#dtExample_" + rowNum).val(data.example); + $("#dtOption_" + rowNum).val(data.option); + }, + isComplete: function() { return $("#dtOption_" + rowNum).length > 0; } + }; + }; + + var _saveRow = function(rowNum) { + return { + "example": $("#dtExample_" + rowNum).val(), + "option": $("#dtOption_" + rowNum).val() + }; + }; + + + manager.registerDataType(MODULE_ID, { + validate: _validate, + loadRow: _loadRow, + saveRow: _saveRow + }); +}); + diff --git a/plugins/dataTypes/Computed/README.md b/plugins/dataTypes/Computed/README.md new file mode 100644 index 000000000..565b69140 --- /dev/null +++ b/plugins/dataTypes/Computed/README.md @@ -0,0 +1,31 @@ +## Company Data Type + +Generates a random company name. + +### Example API Usage + +POST the following JSON content to: `http://[your site]/[generate data folder]/api/v1/data`: + +```javascript +{ + "numRows": 10, + "rows": [ + { + "type": "Company", + "title": "Company name" + } + ], + "export": { + "type": "JSON", + "settings": { + "stripWhitespace": false, + "dataStructureFormat": "simple" + } + } +} +``` + +### API help + +For more information about the API, check out: +[http://benkeen.github.io/generatedata/api.html](http://benkeen.github.io/generatedata/api.html) diff --git a/plugins/dataTypes/Computed/lang/de.php b/plugins/dataTypes/Computed/lang/de.php new file mode 100644 index 000000000..cbc85ea33 --- /dev/null +++ b/plugins/dataTypes/Computed/lang/de.php @@ -0,0 +1,18 @@ + "Berechnet", + "DESC" => "Hier können Sie programmatisch die Werte und Metadaten aus anderen Bereichen in der Reihe und gibt, was Sie wollen erzeugt zugreifen." +); + +$L["see_help_dialog"] = " Siehe Hilfe-Dialog."; +$L["help_para1"] = "Die computerisiert Datentyp gibt Ihnen über Felder in der Zeile auf die Metadaten zugreifen Sie Informationen, was Ausgabe, die Sie lassen generieren auf dieser Grundlage. Wenn Sie nur zugreifen müssen der erzeugt String-Wert aus einem anderen Feld (das heißt, was Sie in der Ausgabe sehen) finden Sie in den Verbund Datentyp . Diese Art von Feld gibt Ihnen viel mehr Zugriff auf jedes Feld."; +$L["help_para2"] = "{\$ROW1}, {\$ROW2} usw. enthält alles, was verfügbar über diese spezielle Reihe. Die inhaltlichen Änderungen, basierend auf den Datentyp der Reihe und welche Bein erzeugt hat, aber auf hoher Ebene enthält die folgenden Eigenschaften:"; +$L["help_prop1"] = "{\$ROW1.OPTIONS} - welche Optionen eingegeben wurden in die Schnittstelle / API-Aufruf für die Zeile"; +$L["help_prop2"] = "{\$ROW1.COL_METADATA} - jede zusätzliche Metadaten für den Datentyp zurückgegeben"; +$L["help_prop3"] = "{\$ROW1.DATA} - die tatsächlichen zufallsgenerierten Inhalte für diesen Bereich (immer in einer Eigenschaft „Anzeige“) sowie alle weiteren Informationen über den erzeugten Inhalt"; +$L["help_prop4"] = "{\$ROW1.DEBUG} - Eine praktische JSON Serialisierung von allem in der Reihe, so können Sie sehen, was verfügbar ist. Führen Sie es einfach durch einen JSON Formatierer ."; +$L["example"] = "Beispiel"; +$L["example1"] = "{\$ROW1.RANDOM_DATA.gender} - wird das Geschlecht („männlich“, „weiblich“ oder „unbekannt“) oder der erzeugte Inhalt einer Namen Feld Datentyp (sicher sein, „1“ mit der rechten Zeilennummer ! ersetzen) ausgegeben. Wenn Sie verwenden FemaleName als Platzhalter Zeichenfolge wird diese Variable \"weiblich\" jedes Mal zurück. Wenn Sie „Name“ eintrat, kehrte der Wert wird auf der erzeugten Zeichenfolge ab. Wenn Sie einen Platzhalter Zeichenfolge mit mehreren Formaten eingegeben, wird er zurückkehren „unbekannt“, wenn es beiden Geschlechter enthalten ist, oder keine Geschlechter (zum Beispiel der Familienname ohne Vornamen)."; diff --git a/plugins/dataTypes/Computed/lang/en.php b/plugins/dataTypes/Computed/lang/en.php new file mode 100644 index 000000000..4d504f527 --- /dev/null +++ b/plugins/dataTypes/Computed/lang/en.php @@ -0,0 +1,18 @@ + "Computed", + "DESC" => "Lets you programmatically access the values and metadata generated from other fields in the row and output whatever you want." +); + +$L["see_help_dialog"] = " See help dialog."; +$L["help_para1"] = "The Computed Data Type gives you access to the metadata about fields in the row to let you generate whatever output you want based on that information. If you just need to access the generated string value from another field (i.e. what you see in the output), see the Composite Data Type. This field type gives you much more access to each field."; +$L["help_para2"] = "{\$ROW1}, {\$ROW2} etc. contain everything available about that particular row. The content changes based on the row's Data Type and what has been generated, but high-level it contains the following properties:"; +$L["help_prop1"] = "{\$ROW1.OPTIONS} - whatever options were entered in the interface/API call for the row"; +$L["help_prop2"] = "{\$ROW1.COL_METADATA} - any additional metadata returned for the Data Type"; +$L["help_prop3"] = "{\$ROW1.DATA} - the actual generated random content for this field (always in a \"display\" property) plus any other information about the generated content"; +$L["help_prop4"] = "{\$ROW1.DEBUG} - a handy JSON-serialization of everything in the row, so you can see what's available. Just run it through a JSON formatter."; +$L["example"] = "Example"; +$L["example1"] = "{\$ROW1.RANDOM_DATA.gender} - will output the gender (\"male\", \"female\" or \"unknown\") of the generated content of a Names Data Type field (be sure to replace \"1\" with the right row number!). If you used FemaleName as the placeholder string this variable will return \"female\" every time. If you entered \"Name\", the value returned will depend on the generated string. If you entered a placeholder string with multiple formats, it will return \"unknown\" if it contained both genders, or no genders (e.g. a surname without a first name)."; diff --git a/plugins/dataTypes/Computed/lang/es.php b/plugins/dataTypes/Computed/lang/es.php new file mode 100644 index 000000000..0d4e7b6fb --- /dev/null +++ b/plugins/dataTypes/Computed/lang/es.php @@ -0,0 +1,18 @@ + "Cpmputarizada", + "DESC" => "Le permite tener acceso mediante programación los valores y los metadatos generados a partir de otros campos de la fila y salidas lo que quieras." +); + +$L["see_help_dialog"] = " Ver diálogo de ayuda."; +$L["help_para1"] = "La Tipo de datos informatizado le da acceso a los metadatos acerca de los campos en la fila para que pueda generar cualquier salida que para la información basado en eso. Si sólo tiene que acceder al generada valor de cadena de otro campo (es decir, lo que se ve en la salida), consulte la Composite Tipo de datos. Este tipo de campo que da mucho más el acceso a cada campo."; +$L["help_para2"] = "{\$ROW1}, {\$ROW2} etcétera, contienen todo lo disponible de esa fila en particular. Los cambios de contenido en función del tipo de datos de la fila y lo que ha generado la pierna, pero de alto nivel que contiene las siguientes propiedades:"; +$L["help_prop1"] = "{\$ROW1.OPTIONS} - todas las opciones que se introdujeron en la llamada interfase / API para la fila"; +$L["help_prop2"] = "{\$ROW1.COL_METADATA} - cualquier metadatos adicionales devuelto para el tipo de datos"; +$L["help_prop3"] = "{\$ROW1.DATA} - el contenido real generado de forma aleatoria para este campo (siempre en una propiedad de \"display\"), además de cualquier otra información sobre el contenido generado"; +$L["help_prop4"] = "{\$ROW1.DEBUG} - un práctico serialización JSON de todo en la fila, para que pueda ver lo que está disponible. Sólo tiene que ejecutar a través de un formateador JSON."; +$L["example"] = "Example"; +$L["example1"] = "{\$ROW1.RANDOM_DATA.gender} - te mostrará el género ( \"male\", \"female\" o \"unknown\") o el contenido generado de un Nombres Tipo de datos (asegúrese de reemplazar \"1\" con el número de fila de la derecha!). Si ha utilizado FemaleName como la cadena de marcador de posición esta variable volverá cada vez \"female\". Si ha introducido \"Name\", el valor devuelto dependerá de la cadena generada. Si ha introducido una cadena marcador de posición con múltiples formatos, devolverá \"unknown\" si contenía ambos sexos, con o sin géneros (por ejemplo, un apellido sin nombre)."; diff --git a/plugins/dataTypes/Computed/lang/fr.php b/plugins/dataTypes/Computed/lang/fr.php new file mode 100644 index 000000000..c140f5cde --- /dev/null +++ b/plugins/dataTypes/Computed/lang/fr.php @@ -0,0 +1,18 @@ + "Calculé", + "DESC" => "Permet d'accéder par programmation les valeurs et les métadonnées générées à partir d'autres champs de la ligne et des sorties tout ce que vous voulez." +); + +$L["see_help_dialog"] = " Voir boîte de dialogue d'aide."; +$L["help_para1"] = "Informatisé type de données donne accès aux métadonnées sur les champs de la ligne pour vous permettre de générer ce que la sortie vous pour obtenir des informations sur cette base. Si vous avez juste besoin d'accéder à la produit valeur de chaîne d'un autre champ (à savoir, ce que vous voyez dans la sortie), voir Composite Type de données. Ce type de champ vous donne accès beaucoup plus à chaque champ."; +$L["help_para2"] = "{\$ROW1}, {\$ROW2} etc. contiennent tout disponible sur cette ligne particulière. Les changements de contenu basé sur le type de données de la ligne et que la jambe a généré, mais de haut niveau, il contient les propriétés suivantes:"; +$L["help_prop1"] = "{\$ROW1.OPTIONS} - les options que ENTRÉES dans l'appel d'interface / API pour la ligne"; +$L["help_prop2"] = "{\$ROW1.COL_METADATA} - les métadonnées supplémentaires renvoyées pour le type de données"; +$L["help_prop3"] = "{\$ROW1.DATA} - le contenu généré de façon aléatoire réelle pour ce champ (toujours dans une propriété « d'affichage ») ainsi que toute autre information sur le contenu généré par"; +$L["help_prop4"] = "{\$ROW1.DEBUG} - un sérialisation JSON à portée de main de tout dans la ligne, afin que vous puissiez voir ce qui est disponible. Il suffit de l'exécuter à travers un formatter JSON."; +$L["example"] = "Exemple"; +$L["example1"] = "{\$ROW1.RANDOM_DATA.gender} - affichera le genre («male», «female» ou «unknown») ou le contenu généré d'un Names Type de données (assurez-vous de remplacer «1» avec le bon numéro de ligne!). Si vous avez utilisé FemaleNamecomme la chaîne de l'espace réservé cette variable retourne à chaque fois « femme ». Si vous saisissez « Nom », la valeur retournée dépendra de la chaîne générée. Si vous avez entré une chaîne d'espace réservé avec plusieurs formats, il retournera « inconnu » si elle contenait les deux sexes, ou aucun sexe (par exemple, un nom de famille sans prénom)."; diff --git a/plugins/dataTypes/Computed/lang/nl.php b/plugins/dataTypes/Computed/lang/nl.php new file mode 100644 index 000000000..8cf7e527b --- /dev/null +++ b/plugins/dataTypes/Computed/lang/nl.php @@ -0,0 +1,18 @@ + "Berekende", + "DESC" => "Hiermee kunt u programmatisch toegang tot de meerwaarden en metadata gegenereerd uit andere velden in de rij en uitgang wat je wilt." +); + +$L["see_help_dialog"] = " Zie dialoog hulp."; +$L["help_para1"] = "De Computed Data Type Geeft u toegang tot de metadata velden in de rij over om u te laten genereren welke uitgang je wilt is gebaseerd Die informatie. Als je gewoon nodig hebt om toegang te krijgen tot de gegenereerd string waarde uit Reviews ander veld (dat wil zeggen wat je ziet in de output), kunt u de Composite Data Type. Dit veld-type Geeft u veel meer toegang tot elkaars vakgebied."; +$L["help_para2"] = "{\$ROW1}, {\$ROW2} etc. bevatten alles wat beschikbaar is over die bepaalde rij. De inhoud uitwisseling op basis van de de rij van Data Type en wat-is gegenereerd, high-level goal Het bevat de volgende eigenschappen:"; +$L["help_prop1"] = "{\$ROW1.OPTIONS} - Werden ingevoerd, wat opties in de interface / API oproep voor de rij"; +$L["help_prop2"] = "{\$ROW1.COL_METADATA} - Eventuele extra metadata terug voor het Data Type"; +$L["help_prop3"] = "{\$ROW1.DATA} - de feitelijke gegenereerde willekeurige blij voor dit gebied (altijd in een \"scherm\" eigendom) plus alle andere informatie over de gegenereerde inhoud"; +$L["help_prop4"] = "{\$ROW1.DEBUG} - een handige JSON-rangschikking van alles in de rij, zodat u kunt zien wat er beschikbaar is. Draaien gewoon door een JSON formatter."; +$L["example"] = "Voorbeeld"; +$L["example1"] = "{\$ROW1.RANDOM_DATA.gender} - dit zal de uitgang van het geslacht (\"MaleName\", \"FemaleName\" of \"Unknown\") van de gegenereerde inhoud van de Names Data Type veld (zuur zijn om te vervangen \"1\" met de juiste rijnummer!) . Als je gewend FemaleName als tijdelijke aanduiding string deze variabele \"vrouwelijke\" iedere keer terug te keren. Als u \"Name\" ingevoerd, wordt de waarde die wordt geretourneerd zal afhangen van de gegenereerde string. Als u een placeholder string met meerdere formaten ingevoerd, zal het terug \"onbekend\" als het bevatte zowel mannen als vrouwen, geslachten of geen (bijvoorbeeld een familienaam zonder voornaam)."; diff --git a/plugins/dataTypes/Names/Names.class.php b/plugins/dataTypes/Names/Names.class.php index d0e3ceabe..c2a4542a2 100644 --- a/plugins/dataTypes/Names/Names.class.php +++ b/plugins/dataTypes/Names/Names.class.php @@ -14,11 +14,12 @@ class DataType_Names extends DataTypePlugin { protected $jsModules = array("Names.js"); // custom member vars for this Data Type - private $maleNames = array(); - private $femaleNames = array(); - private $firstNames = array(); - private $lastNames = array(); - private $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private $firstNames = array(); + private $maleNames = array(); + private $femaleNames = array(); + private $lastNames = array(); + private $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private $genders = array("male", "female"); /** @@ -36,31 +37,56 @@ public function __construct($runtimeContext) { public function generate($generator, $generationContextData) { $placeholderStr = $generationContextData["generationOptions"]; - while (preg_match("/MaleName/", $placeholderStr)) { - $placeholderStr = preg_replace("/MaleName/", $this->getRandomFirstName($this->maleNames), $placeholderStr, 1); + // in case the user entered multiple | separated formats, pick one first. + $formats = explode("|", $placeholderStr); + $chosenFormat = $formats[0]; + if (count($formats) > 1) { + $chosenFormat = $formats[mt_rand(0, count($formats)-1)]; + } + + // the placeholder string with all the placeholders removed + $output = $chosenFormat; + + // the user can enter any old thing in the place holder field. We do our best to return some "gender" metadata + // based on what we find. In case we find multiple genders, we return "unknown" + $found_genders = []; + + while (preg_match("/MaleName/", $output)) { + $found_genders[] = "male"; + $output = preg_replace("/MaleName/", $this->getRandomFirstName($this->maleNames), $output, 1); } - while (preg_match("/FemaleName/", $placeholderStr)) { - $placeholderStr = preg_replace("/FemaleName/", $this->getRandomFirstName($this->femaleNames), $placeholderStr, 1); + while (preg_match("/FemaleName/", $output)) { + $found_genders[] = "female"; + $output = preg_replace("/FemaleName/", $this->getRandomFirstName($this->femaleNames), $output, 1); } - while (preg_match("/Name/", $placeholderStr)) { - $placeholderStr = preg_replace("/Name/", $this->getRandomFirstName($this->firstNames), $placeholderStr, 1); + while (preg_match("/Name/", $output)) { + // pick a random gender + $index = mt_rand(0, 1); + $gender = $this->genders[$index]; + $found_genders[] = $gender; + $source = ($gender === "male") ? $this->maleNames : $this->femaleNames; + $output = preg_replace("/Name/", $this->getRandomFirstName($source), $output, 1); } - while (preg_match("/Surname/", $placeholderStr)) { - $placeholderStr = preg_replace("/Surname/", $this->lastNames[mt_rand(0, count($this->lastNames)-1)], $placeholderStr, 1); + while (preg_match("/Surname/", $output)) { + $output = preg_replace("/Surname/", $this->lastNames[mt_rand(0, count($this->lastNames)-1)], $output, 1); } - while (preg_match("/Initial/", $placeholderStr)) { - $placeholderStr = preg_replace("/Initial/", $this->letters[mt_rand(0, strlen($this->letters)-1)], $placeholderStr, 1); + while (preg_match("/Initial/", $output)) { + $output = preg_replace("/Initial/", $this->letters[mt_rand(0, strlen($this->letters)-1)], $output, 1); } - // in case the user entered multiple | separated formats, pick one - $formats = explode("|", $placeholderStr); - $chosenFormat = $formats[0]; - if (count($formats) > 1) { - $chosenFormat = $formats[mt_rand(0, count($formats)-1)]; - } + $gender = "unknown"; + if (count($found_genders) == 1){ + $gender = $found_genders[0]; + } else if (count($found_genders) > 1) { + $uniques = array_unique($found_genders); + if (count($uniques) == 1) { + $gender = $uniques[0]; + } + } return array( - "display" => trim($chosenFormat) + "display" => trim($output), + "gender" => $gender ); } @@ -79,7 +105,6 @@ public function getRowGenerationOptionsAPI($generator, $json, $numCols) { return $json->settings->placeholder; } - public function getDataTypeMetadata() { return array( "SQLField" => "varchar(255) default NULL", @@ -114,10 +139,6 @@ public function getOptionsColumnHTML() { return ''; } - public function getNames() { - return $this->firstNames; - } - public function getFirstNames() { return $this->firstNames; } @@ -141,7 +162,7 @@ private function initFirstNames() { "); if ($response["success"]) { - $names = array(); + $names = array(); $maleNames = array(); $femaleNames = array(); while ($row = mysqli_fetch_assoc($response["results"])) { @@ -156,9 +177,9 @@ private function initFirstNames() { } } - $this->firstNames = $names; $this->maleNames = $maleNames; $this->femaleNames = $femaleNames; + $this->firstNames = $names; } } diff --git a/plugins/dataTypes/NamesRegional/NamesRegional.class.php b/plugins/dataTypes/NamesRegional/NamesRegional.class.php index 6b48227f4..7e4768e87 100644 --- a/plugins/dataTypes/NamesRegional/NamesRegional.class.php +++ b/plugins/dataTypes/NamesRegional/NamesRegional.class.php @@ -479,10 +479,6 @@ public function getOptionsColumnHTML() { return ''; } - public function getNames() { - return $this->firstNames; - } - public function getFirstNames() { return $this->firstNames; } diff --git a/plugins/dataTypes/PersonalNumber/lang/en.php b/plugins/dataTypes/PersonalNumber/lang/en.php index b01eaaf9c..a36da6184 100644 --- a/plugins/dataTypes/PersonalNumber/lang/en.php +++ b/plugins/dataTypes/PersonalNumber/lang/en.php @@ -4,7 +4,7 @@ $L["DATA_TYPE"] = array( "NAME" => "Personal Number", - "DESC" => "Generates personal number, used in some countries for social security insurance." + "DESC" => "Generates a personal number, used in some countries for social security insurance." ); $L["help_text"] = "At the present time only swedish ones are supported. The personal numbers are generated according to the format you specify:"; diff --git a/plugins/dataTypes/Region/Region.class.php b/plugins/dataTypes/Region/Region.class.php index 07ecd60c1..90c1707d8 100644 --- a/plugins/dataTypes/Region/Region.class.php +++ b/plugins/dataTypes/Region/Region.class.php @@ -196,7 +196,7 @@ public function getDataTypeMetadata() { private function getRandIndex($options, $randCountrySlug) { $index = null; if ($options[$randCountrySlug]["full"] == 1 && $options[$randCountrySlug]["short"] == 1) { - $index = mt_rand(0, 1); // weird, mt_rand()&1 doesn't work - always returns 1 0 1 0 1 0... + $index = mt_rand(0, 1); } else if ($options[$randCountrySlug]["full"] == 1) { $index = 0; } else if ($options[$randCountrySlug]["short"] == 1) { diff --git a/plugins/dataTypes/Rut/Rut.class.php b/plugins/dataTypes/Rut/Rut.class.php index 0fd5182e1..6ab690f7a 100644 --- a/plugins/dataTypes/Rut/Rut.class.php +++ b/plugins/dataTypes/Rut/Rut.class.php @@ -12,77 +12,54 @@ class DataType_Rut extends DataTypePlugin { protected $dataTypeFieldGroupOrder = 105; protected $jsModules = array("Rut.js"); - public function __construct($runtimeContext) { - parent::__construct($runtimeContext); - if ($runtimeContext == "generation") { - - } - } - public function generate($generator, $generationContextData) { $options = $generationContextData["generationOptions"]; $rowRutInfo = array(); - while (list($key, $info) = each($generationContextData["existingRowData"])) - { - if ($info["dataTypeFolder"] == "Rut") - { + while (list($key, $info) = each($generationContextData["existingRowData"])) { + if ($info["dataTypeFolder"] == "Rut") { $rowRutInfo = $info; break; } } reset($generationContextData["existingRowData"]); - if (!empty($rowRutInfo)) - { + if (!empty($rowRutInfo)) { $rutn = $info["randomData"]["rut"]; $digit = $info["randomData"]["digit"]; - } - else - { + } else { $rutn = sprintf("%d%03d%03d", mt_rand(5, 50), mt_rand(0,999), mt_rand(0,999)); $digit = $this->getDigit($rutn); } $display = ""; - if( strpos($options["formatCode"], "xxxxxxxx") !== false ) - { - if( $options["thousep"] ) - { + if (strpos($options["formatCode"], "xxxxxxxx") !== false) { + if ($options["thousep"]) { $display = number_format($rutn, 0, ",", "."); - } - else - { + } else { $display = $rutn; } } - if( strpos($options["formatCode"], "xxxxxxxx-y") !== false ) - { - if( !$options["remdash"] ) - { + if (strpos($options["formatCode"], "xxxxxxxx-y") !== false) { + if (!$options["remdash"]) { $display .= "-"; } } - if( strpos($options["formatCode"], "y") !== false ) - { - if( $options["upper"] ) - { + if (strpos($options["formatCode"], "y") !== false) { + if ($options["upper"]) { $display .= strtoupper($digit); - } - else - { + } else { $display .= $digit; } } - return array - ( + return array( "display" => $display, - "rut" => $rutn, - "digit" => $digit + "rut" => $rutn, + "digit" => $digit ); } diff --git a/resources/classes/Core.class.php b/resources/classes/Core.class.php index c0039a6e5..ceac476c2 100644 --- a/resources/classes/Core.class.php +++ b/resources/classes/Core.class.php @@ -35,8 +35,8 @@ class Core { private static $apiEnabled = false; // non-overridable settings - private static $version = "3.2.6"; - private static $releaseDate = "2017-04-17"; + private static $version = "3.2.7"; + private static $releaseDate = "2017-07-29"; private static $minimumPHPVersion = "5.3.0"; private static $minimumMySQLVersion = "4.1.3"; private static $settingsFileExists = false;