-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
419 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
require_once("library.php"); | ||
|
||
$json =<<< END | ||
{ | ||
"numRows": 1000, | ||
"rows": [ | ||
{ | ||
"type": "Names", | ||
"title": "First Name", | ||
"settings": { | ||
"placeholder": "Name" | ||
} | ||
}, | ||
{ | ||
"type": "Names", | ||
"title": "Last Name", | ||
"settings": { | ||
"placeholder": "Surname" | ||
} | ||
}, | ||
{ | ||
"type": "Email", | ||
"title": "Email" | ||
}, | ||
{ | ||
"type": "AlphaNumeric", | ||
"title": "Random Password", | ||
"settings": { | ||
"placeholder": "LLLxxLLLxLL" | ||
} | ||
}, | ||
{ | ||
"type": "AlphaNumeric", | ||
"title": "US Zipcode", | ||
"settings": { | ||
"placeholder": "xxxxx" | ||
} | ||
} | ||
], | ||
"export": { | ||
"type": "JSON", | ||
"settings": { | ||
"stripWhitespace": false, | ||
"dataStructureFormat": "simple" | ||
} | ||
} | ||
} | ||
END; | ||
|
||
$url = "http://localhost:8888/generatedata/api/v1/data"; | ||
$ch = curl_init($url); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
|
||
$response = curl_exec($ch); | ||
curl_close($ch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
/** | ||
* @package DataTypes | ||
*/ | ||
|
||
class DataType_Computed extends DataTypePlugin { | ||
|
||
protected $isEnabled = true; | ||
protected $dataTypeName = "Computed"; | ||
protected $hasHelpDialog = true; | ||
protected $dataTypeFieldGroup = "other"; | ||
protected $dataTypeFieldGroupOrder = 60; | ||
private $smarty; | ||
|
||
// this should always be highest for all Data Types. Point is, this Data Type needs to be able to access the | ||
// result of all other fields to work. Composite works similarly, but it has a lower process order (150) so this | ||
// field trumps everything and executes last | ||
protected $processOrder = 200; | ||
|
||
public function __construct($runtimeContext) { | ||
parent::__construct($runtimeContext); | ||
if ($runtimeContext == "generation") { | ||
$this->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 '<textarea name="dtOption_%ROW%" id="dtOption_%ROW%" style="height: 70px; width: 260px"></textarea>'; | ||
} | ||
|
||
public function getHelpHTML() { | ||
$content =<<<EOF | ||
<p> | ||
{$this->L["help_para1"]} | ||
</p> | ||
<p> | ||
{$this->L["help_para2"]} | ||
</p> | ||
<ul> | ||
<li>{$this->L["help_prop1"]}</li> | ||
<li>{$this->L["help_prop2"]}</li> | ||
<li>{$this->L["help_prop3"]}</li> | ||
<li>{$this->L["help_prop4"]}</li> | ||
</ul> | ||
<b>{$this->L["example"]}</b> | ||
<ul> | ||
<li>{$this->L["example1"]}</li> | ||
</ul> | ||
EOF; | ||
|
||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<rows.length; i++) { | ||
if ($("#dtOption_" + rows[i]).val() === "") { | ||
var visibleRowNum = generator.getVisibleRowOrderByRowNum(rows[i]); | ||
visibleProblemRows.push(visibleRowNum); | ||
problemFields.push($("#option_" + rows[i])); | ||
} | ||
} | ||
|
||
var errors = []; | ||
if (visibleProblemRows.length) { | ||
errors.push({ els: problemFields, error: L.AlphaNumeric_incomplete_fields + " <b>" + visibleProblemRows.join(", ") + "</b>"}); | ||
} | ||
|
||
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 | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$L = array(); | ||
|
||
$L["DATA_TYPE"] = array( | ||
"NAME" => "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 <b>computerisiert</b> 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 <i>erzeugt</i> String-Wert aus einem anderen Feld (das heißt, was Sie in der Ausgabe sehen) finden Sie in den <b>Verbund</b> Datentyp . Diese Art von Feld gibt Ihnen viel mehr Zugriff auf jedes Feld."; | ||
$L["help_para2"] = "<b>{\$ROW1}</b>, <b>{\$ROW2}</b> 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"] = "<b>{\$ROW1.OPTIONS}</b> - welche Optionen eingegeben wurden in die Schnittstelle / API-Aufruf für die Zeile"; | ||
$L["help_prop2"] = "<b>{\$ROW1.COL_METADATA}</b> - jede zusätzliche Metadaten für den Datentyp zurückgegeben"; | ||
$L["help_prop3"] = "<b>{\$ROW1.DATA}</b> - 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"] = "<b>{\$ROW1.DEBUG}</b> - 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"] = "<b>{\$ROW1.RANDOM_DATA.gender}</b> - wird das Geschlecht („männlich“, „weiblich“ oder „unbekannt“) oder der erzeugte Inhalt einer <b>Namen</b> Feld Datentyp (sicher sein, „1“ mit der rechten Zeilennummer ! ersetzen) ausgegeben. Wenn Sie verwenden <b>FemaleName</b> 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)."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$L = array(); | ||
|
||
$L["DATA_TYPE"] = array( | ||
"NAME" => "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 <b>Computed</b> 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 <i>generated</i> string value from another field (i.e. what you see in the output), see the <b>Composite</b> Data Type. This field type gives you much more access to each field."; | ||
$L["help_para2"] = "<b>{\$ROW1}</b>, <b>{\$ROW2}</b> 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"] = "<b>{\$ROW1.OPTIONS}</b> - whatever options were entered in the interface/API call for the row"; | ||
$L["help_prop2"] = "<b>{\$ROW1.COL_METADATA}</b> - any additional metadata returned for the Data Type"; | ||
$L["help_prop3"] = "<b>{\$ROW1.DATA}</b> - the actual generated random content for this field (always in a \"display\" property) plus any other information about the generated content"; | ||
$L["help_prop4"] = "<b>{\$ROW1.DEBUG}</b> - 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"] = "<b>{\$ROW1.RANDOM_DATA.gender}</b> - will output the gender (\"male\", \"female\" or \"unknown\") of the generated content of a <b>Names</b> Data Type field (be sure to replace \"1\" with the right row number!). If you used <b>FemaleName</b> 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)."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$L = array(); | ||
|
||
$L["DATA_TYPE"] = array( | ||
"NAME" => "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 <b>Tipo de datos</b> 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 <i>generada</i> valor de cadena de otro campo (es decir, lo que se ve en la salida), consulte la <b>Composite</b> Tipo de datos. Este tipo de campo que da mucho más el acceso a cada campo."; | ||
$L["help_para2"] = "<b>{\$ROW1}</b>, <b>{\$ROW2}</b> 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"] = "<b>{\$ROW1.OPTIONS}</b> - todas las opciones que se introdujeron en la llamada interfase / API para la fila"; | ||
$L["help_prop2"] = "<b>{\$ROW1.COL_METADATA}</b> - cualquier metadatos adicionales devuelto para el tipo de datos"; | ||
$L["help_prop3"] = "<b>{\$ROW1.DATA}</b> - 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"] = "<b>{\$ROW1.DEBUG}</b> - 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"] = "<b>{\$ROW1.RANDOM_DATA.gender}</b> - te mostrará el género ( \"male\", \"female\" o \"unknown\") o el contenido generado de un <b>Nombres</b> Tipo de datos (asegúrese de reemplazar \"1\" con el número de fila de la derecha!). Si ha utilizado <b>FemaleName</b> 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)."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$L = array(); | ||
|
||
$L["DATA_TYPE"] = array( | ||
"NAME" => "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"] = "<b>Informatisé</b> 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 <i>produit</i> valeur de chaîne d'un autre champ (à savoir, ce que vous voyez dans la sortie), voir <b>Composite</b> Type de données. Ce type de champ vous donne accès beaucoup plus à chaque champ."; | ||
$L["help_para2"] = "<b>{\$ROW1}</b>, <b>{\$ROW2}</b> 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"] = "<b>{\$ROW1.OPTIONS}</b> - les options que ENTRÉES dans l'appel d'interface / API pour la ligne"; | ||
$L["help_prop2"] = "<b>{\$ROW1.COL_METADATA}</b> - les métadonnées supplémentaires renvoyées pour le type de données"; | ||
$L["help_prop3"] = "<b>{\$ROW1.DATA}</b> - 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"] = "<b>{\$ROW1.DEBUG}</b> - 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"] = "<b>{\$ROW1.RANDOM_DATA.gender}</b> - affichera le genre («male», «female» ou «unknown») ou le contenu généré d'un <b>Names</b> Type de données (assurez-vous de remplacer «1» avec le bon numéro de ligne!). Si vous avez utilisé <b>FemaleName</b>comme 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)."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
$L = array(); | ||
|
||
$L["DATA_TYPE"] = array( | ||
"NAME" => "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 <b>Computed</b> 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 <b>Composite</b> Data Type. Dit veld-type Geeft u veel meer toegang tot elkaars vakgebied."; | ||
$L["help_para2"] = "<b>{\$ROW1}</b>, <b>{\$ROW2}</b> 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"] = "<b>{\$ROW1.OPTIONS}</b> - Werden ingevoerd, wat opties in de interface / API oproep voor de rij"; | ||
$L["help_prop2"] = "<b>{\$ROW1.COL_METADATA}</b> - Eventuele extra metadata terug voor het Data Type"; | ||
$L["help_prop3"] = "<b>{\$ROW1.DATA}</b> - de feitelijke gegenereerde willekeurige blij voor dit gebied (altijd in een \"scherm\" eigendom) plus alle andere informatie over de gegenereerde inhoud"; | ||
$L["help_prop4"] = "<b>{\$ROW1.DEBUG}</b> - 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"] = "<b>{\$ROW1.RANDOM_DATA.gender}</b> - dit zal de uitgang van het geslacht (\"MaleName\", \"FemaleName\" of \"Unknown\") van de gegenereerde inhoud van de <b>Names</b> Data Type veld (zuur zijn om te vervangen \"1\" met de juiste rijnummer!) . Als je gewend <b>FemaleName</b> 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)."; |
Oops, something went wrong.