Skip to content

Commit

Permalink
bf PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Sep 29, 2023
1 parent 7186ca9 commit ce3036c
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 79 deletions.
Binary file added Build/4DPop AppMaker.dmg
Binary file not shown.
Binary file modified Build/Components/4DPop AppMaker.4dbase/4DPop AppMaker.4DZ
Binary file not shown.
8 changes: 4 additions & 4 deletions Build/Components/4DPop AppMaker.4dbase/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleVersion</key>
<string>556</string>
<string>557</string>
<key>CFBundleDisplayName</key>
<string>4DPop AppMaker</string>
<key>CFBundleShortVersionString</key>
<string>20</string>
<string>20R4</string>
<key>CFBundleGetInfoString</key>
<string>20</string>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20 (555)</string>
<string>20R4 (556)</string>
<key>CFBundleName</key>
<string>4DPop AppMaker</string>
</dict>
Expand Down
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<key>NSHumanReadableCopyright</key>
<string>©vdl 2009-2023</string>
<key>CFBundleVersion</key>
<string>556</string>
<string>557</string>
<key>CFBundleDisplayName</key>
<string>4DPop AppMaker</string>
<key>CFBundleShortVersionString</key>
<string>20</string>
<string>20R4</string>
<key>CFBundleGetInfoString</key>
<string>20</string>
<string>20R4</string>
<key>CFBundleLongVersionString</key>
<string>20 (555)</string>
<string>20R4 (556)</string>
<key>CFBundleName</key>
<string>4DPop AppMaker</string>
</dict>
Expand Down
192 changes: 123 additions & 69 deletions Project/Sources/Classes/xml.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Class constructor($variable)

//———————————————————————————————————————————————————————————
// Creates a XML tree in memory
Function newRef($root : Text)->$this : cs:C1710.xml
Function newRef($root : Text; $nameSpace : Text)->$this : cs:C1710.xml

var ${2} : Text
var ${3} : Text
var $t : Text
var $countParam; $i : Integer

Expand All @@ -48,7 +48,7 @@ Function newRef($root : Text)->$this : cs:C1710.xml
//______________________________________________________
: ($countParam=2) // -> root + namespace

This:C1470.root:=DOM Create XML Ref:C861($root; $2)
This:C1470.root:=DOM Create XML Ref:C861($root; $nameSpace)

//______________________________________________________
: (($countParam%2)=0) // -> root + namespace's pairs
Expand All @@ -68,7 +68,7 @@ Function newRef($root : Text)->$this : cs:C1710.xml
//______________________________________________________
Else // -> root + namespace + namespace's pairs

$t:="DOM Create XML Ref:C861("+$root+";"+$1
$t:="DOM Create XML Ref:C861("+$root+";"+$nameSpace

For ($i; 2; $countParam; 2)

Expand All @@ -87,6 +87,30 @@ Function newRef($root : Text)->$this : cs:C1710.xml

$this:=This:C1470

//———————————————————————————————————————————————————————————
// Defines the options concerning the encoding and the standalone property of the tree
Function setDeclaration($encoding : Text; $standalone : Boolean)

Case of

//____________________________________________
: (Count parameters:C259=0) // Defaults values

DOM SET XML DECLARATION:C859(This:C1470.root; "UTF-8"; False:C215)

//____________________________________________
: (Count parameters:C259=1)

DOM SET XML DECLARATION:C859(This:C1470.root; $encoding; False:C215)

//____________________________________________
: (Count parameters:C259=2)

DOM SET XML DECLARATION:C859(This:C1470.root; $encoding; $standalone)

//____________________________________________
End case

//———————————————————————————————————————————————————————————
// Set the value of one option for the structure
Function setOption($selector : Integer; $value : Integer)->$this : cs:C1710.xml
Expand Down Expand Up @@ -431,21 +455,23 @@ Function append($target : Text; $source : Text)->$node : Text

End if

//———————————————————————————————————————————————————————————
// Append a comment to the target element
Function comment($target : Text; $comment : Text) : Text

If (This:C1470._requiredParams(Count parameters:C259; 1))

return DOM Append XML child node:C1080($target; XML comment:K45:8; $comment)

End if

//———————————————————————————————————————————————————————————
// Insert a XML element among the child elements of the $target element
Function insert($target : Text; $source : Text; $index : Integer)->$node : Text

var $indx : Integer

If (This:C1470._requiredParams(Count parameters:C259; 2))

If (Count parameters:C259>=3)

$indx:=$index

End if

$node:=DOM Insert XML element:C1083($target; $source; $indx)
$node:=DOM Insert XML element:C1083($target; $source; $index)
This:C1470.success:=Bool:C1537(OK)

End if
Expand Down Expand Up @@ -611,7 +637,7 @@ Function toList($refPtr : Pointer; $xpath : Text; $root : Text) : Integer
If ($name#"")

APPEND TO LIST:C376($list; $name; $ref)
SET LIST ITEM PARAMETER:C986($list; 0; "Value"; $value)
SET LIST ITEM PARAMETER:C986($list; 0; "value"; This:C1470._convert($value))
SET LIST ITEM PARAMETER:C986($list; 0; "dom"; $root)

For ($i; 1; $count; 1)
Expand Down Expand Up @@ -1239,7 +1265,7 @@ Function popAttribute($node : Text; $attribute : Text)->$value
// Returns a node attributes as object
Function getAttributes($node : Text)->$attributes : Object

var $key; $nodeƒ; $t; $value : Text
var $key; $nodeƒ; $value : Text
var $i : Integer

If (This:C1470._requiredParams(Count parameters:C259; 1))
Expand All @@ -1259,8 +1285,6 @@ Function getAttributes($node : Text)->$attributes : Object

$attributes:=New object:C1471

GET SYSTEM FORMAT:C994(Decimal separator:K60:1; $t)

For ($i; 1; DOM Count XML attributes:C727($nodeƒ); 1)

DOM GET XML ATTRIBUTE BY INDEX:C729($nodeƒ; $i; $key; $value)
Expand Down Expand Up @@ -1289,7 +1313,22 @@ Function setAttribute($node : Text; $name : Text; $value)->$this : cs:C1710.xml

If (This:C1470._requiredRef($node))

DOM SET XML ATTRIBUTE:C866($node; $name; $value)
Case of
//______________________________________________________
: (Value type:C1509($value)=Is collection:K8:32)\
| (Value type:C1509($value)=Is object:K8:27)

DOM SET XML ATTRIBUTE:C866($node; $name; JSON Stringify:C1217($value))

//______________________________________________________
Else

DOM SET XML ATTRIBUTE:C866($node; $name; $value)

//______________________________________________________
End case


This:C1470.success:=Bool:C1537(OK)

End if
Expand All @@ -1299,71 +1338,81 @@ Function setAttribute($node : Text; $name : Text; $value)->$this : cs:C1710.xml

// —————————————————————————————————————————————————————————————————————————————————
// Set a node attributes from an object or a collection (key/value pairs)
Function setAttributes($node : Text; $attributes; $value)->$this : cs:C1710.xml
Function setAttributes($node : Text; $attributes; $value) : cs:C1710.xml

var $t : Text
var $o : Object
var $val

If (This:C1470._requiredParams(Count parameters:C259; 2))
If (This:C1470._requiredParams(Count parameters:C259; 2)) && (This:C1470._requiredRef($node))

If (This:C1470._requiredRef($node))

Case of
Case of

//______________________________________________________
: (Value type:C1509($attributes)=Is text:K8:3)

If (This:C1470._requiredParams(Count parameters:C259; 3))

//______________________________________________________
: (Value type:C1509($attributes)=Is text:K8:3)
This:C1470.setAttribute($node; $attributes; $value)

If (This:C1470._requiredParams(Count parameters:C259; 3))

This:C1470.setAttribute($node; $attributes; $value)

End if
End if

//______________________________________________________
: (Value type:C1509($attributes)=Is object:K8:27)

For each ($t; $attributes) While (This:C1470.success)

//______________________________________________________
: (Value type:C1509($attributes)=Is object:K8:27)
$val:=$attributes[$t]
DOM SET XML ATTRIBUTE:C866($node; $t; $val)

For each ($t; $attributes) While (This:C1470.success)

DOM SET XML ATTRIBUTE:C866($node; \
$t; $attributes[$t])
This:C1470.success:=Bool:C1537(OK)

End for each
This:C1470.success:=Bool:C1537(OK)

If (Not:C34(This:C1470.success))

This:C1470.errors.push(Current method name:C684+" - Failed to set attribute \""+$t+"\"")
break

End if
End for each

//______________________________________________________
: (Value type:C1509($attributes)=Is collection:K8:32)

For each ($o; $attributes) While (This:C1470.success)

//______________________________________________________
: (Value type:C1509($attributes)=Is collection:K8:32)

For each ($o; $attributes) While (This:C1470.success)
If (Value type:C1509($o.value)=Is object:K8:27)\
| (Value type:C1509($o.value)=Is collection:K8:32)

DOM SET XML ATTRIBUTE:C866($node; \
String:C10($o.key); $o.value)
This:C1470.success:=Bool:C1537(OK)
DOM SET XML ATTRIBUTE:C866($node; String:C10($o.key); JSON Stringify:C1217($o.value))

If (Not:C34(This:C1470.success))

This:C1470.errors.push(Current method name:C684+" - Failed to set attribute \""+String:C10($o.key)+"\"")

End if
End for each

//______________________________________________________
Else
Else

$val:=$o.value
DOM SET XML ATTRIBUTE:C866($node; String:C10($o.key); $val)

End if

This:C1470.success:=False:C215
This:C1470.errors.push(Current method name:C684+" - Unmanaged type: "+String:C10(Value type:C1509($node)))
This:C1470.success:=Bool:C1537(OK)

//______________________________________________________
End case
End if
If (Not:C34(This:C1470.success))

This:C1470.errors.push(Current method name:C684+" - Failed to set attribute \""+String:C10($o.key)+"\"")
break

End if
End for each

//______________________________________________________
Else

This:C1470.success:=False:C215
This:C1470.errors.push(Current method name:C684+" - Unmanaged type: "+String:C10(Value type:C1509($node)))

//______________________________________________________
End case
End if

$this:=This:C1470
return This:C1470

// —————————————————————————————————————————————————————————————————————————————————
// Removes, if it exists, the attribute designated by $name from the XML $node
Expand Down Expand Up @@ -1450,35 +1499,40 @@ Function _requiredRef($reference : Text)->$response : Boolean
This:C1470.success:=$response

// —————————————————————————————————————————————————————————————————————————————————
Function _requiredParams($count; $number)->$response : Boolean
Function _requiredParams($count; $number) : Boolean

$response:=$count>=$number
This:C1470.success:=$count>=$number

If (Not:C34($response))
If (Not:C34(This:C1470.success))

This:C1470._pushError("Missing one or more parameters")

End if

This:C1470.success:=$response
return This:C1470.success

// —————————————————————————————————————————————————————————————————————————————————
Function _convert($textValue : Text)->$value

Case of

//______________________________________________________
: (Match regex:C1019("(?m-is)^(?:[tT]rue|[fF]alse)$"; $textValue; 1))
: (Match regex:C1019("(?mi-s)^\\[.*\\]$"; $textValue; 1; *))

$value:=JSON Parse:C1218($textValue)

//______________________________________________________
: (Match regex:C1019("(?m-is)^(?:[tT]rue|[fF]alse)$"; $textValue; 1; *))

$value:=($textValue="true")

//______________________________________________________
: (Match regex:C1019("(?m-si)^(?:\\+|-)?\\d+(?:\\.|"+$textValue+"\\d+)?$"; $textValue; 1))
: (Match regex:C1019("(?m-si)^(?:\\+|-)?\\d+(?:\\.\\d+)?$"; $textValue; 1; *))

$value:=Num:C11($textValue)
$value:=Num:C11($textValue; ".")

//______________________________________________________
: (Match regex:C1019("(?m-si)^\\d+-\\d+-\\d+$"; $textValue; 1))
: (Match regex:C1019("(?m-si)^\\d+-\\d+-\\d+$"; $textValue; 1; *))

$value:=Date:C102($textValue+"T00:00:00")

Expand Down
2 changes: 1 addition & 1 deletion Project/Sources/Methods/APP MAKER HANDLER.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Case of
//================================================================================
: ($action="_deinit")

$success:=PHP Execute:C1058(""; "quit_4d_php")
//$success:=PHP Execute(""; "quit_4d_php")

//================================================================================
Else
Expand Down
Binary file modified Resources/InfoPlist.strings
Binary file not shown.
2 changes: 1 addition & 1 deletion lastbuild
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20
20R4

0 comments on commit ce3036c

Please sign in to comment.