Skip to content

Latest commit

 

History

History
313 lines (242 loc) · 6.16 KB

Menu-Documentation.pod

File metadata and controls

313 lines (242 loc) · 6.16 KB

Class Menu Documentation

Description

Class Menu - XML Generator for DHTMLX

construct

$menu = new Menu( set encoding, default utf-8 )

$menu = new Menu;

or

$menu = new Menu('iso-8859-1');

item

$menu->item( array( 'key attribute' => 'value attribute' ) )

$menu->item(
    array(
        "id" => "file",
        "text" => "File",
        "item" => array(
            array("id" => "new", "text" => "New"),
            array("id" => "ms1", "type" => "separator"),
            array("id" => "export", "text" => "Export")
        )
    )
);

userdata

$menu->userdata( array( 'key attribute' => 'value attribute' ) )

$menu->userdata(
    array(
        "name" => "some1",
        "value" => "Value1"
    ),
    array(
        "name" => "some2",
        "value" => "Value2"
    )
);

start and end

$menu->start( array( 'key attribute' => 'value attribute' ) ) and $menu->end()

$menu->start(
    array(
        "id" => "file",
        "text" => "File"
    )
);

$menu->userdata(
    array(
        "name" => "some1",
        "value" => "Value1"
    )
);

$menu->item(
    array(
        "id" => "new", 
        "text" => "New"
    ),
    array(
        "id" => "ms1", 
        "type" => "separator"
    ),
    array(
        "id" => "export", 
        "text" => "Export"
    )
);

$menu->end();

header

$menu->header()

$menu->header();

return

header("Content-type: application/xml; charset=utf-8");

result

$menu->result()

echo $menu->result();

Print XML

Examples

Example 1

Mode 1

<?php
include_once 'DHX.php';

$menu = new Menu;

$menu->item(
    array(
        "id" => "file",
        "text" => "File",
        "item" => array(
            array("id" => "new", "text" => "New"),
            array("id" => "ms1", "type" => "separator"),
            array("id" => "export", "text" => "Export")
        )
    )
);

$menu->header();
echo $menu->result();
?>

Result

<?xml version="1.0" encoding="utf-8"?>
<menu>
    <item id="file" text="File">
        <item id="new" text="New"/>
        <item id="ms1" type="separator"/>
        <item id="export" text="Export"/>
    </item>
</menu>

Mode 2

<?php
include_once 'DHX.php';

$menu = new Menu("iso-8859-1");

$menu->start(
    array(
        "id" => "file",
        "text" => "File"
    )
);

$menu->item(
    array("id" => "new", "text" => "New"),
    array("id" => "ms1", "type" => "separator"),
    array("id" => "export", "text" => "Export")
);

$menu->end();

$menu->header();
echo $menu->result();
?>

Result

<?xml version="1.0" encoding="iso-8859-1"?>
<menu>
    <item id="file" text="File">
        <item id="new" text="New"/>
        <item id="ms1" type="separator"/>
        <item id="export" text="Export"/>
    </item>
</menu>

Example 2

Mode 1

<?php
include_once 'DHX.php';

$menu = new Menu;

$menu->item(
    array(
        "id" => "file",
        "text" => "File",
        "userdata" => array(
            "name" => "some1",
            "value" => "Value 1"
        ),
        "item" => array(
            array(
                "id" => "new",
                "text" => "New"
            ),
            array(
                "id" => "ms1",
                "type" => "separator"
            ),
            array(
                "id" => "export",
                "text" => "Export",
                "item" => array(
                    array(
                        "id" => "export_pdf",
                        "text" => "PDF",
                        "enabled" => "false"
                    )
                )
            )
        )
    )
);

$menu->header();
echo $menu->result();
?>

Result

<?xml version="1.0" encoding="utf-8"?>
<menu>
    <item id="file" text="File">
        <userdata name="some1">Value 1</userdata>
        <item id="new" text="New"/>
        <item id="ms1" type="separator"/>
        <item id="export" text="Export">
            <item id="export_pdf" text="PDF" enabled="false"/>
        </item>
    </item>
</menu>

Mode 2

<?php
include_once 'DHX.php';

$menu = new Menu("iso-8859-1");

// start file
$menu->start(
    array(
        "id" => "file",
        "text" => "File"
    )
);

$menu->userdata(
    array(
        "name" => "some1",
        "value" => "Value 1"
    )
);

$menu->item(
    array(
        "id" => "new",
        "text" => "New"
    ),
    array(
        "id" => "ms1",
        "type" => "separator"
    )
);

// start export
$menu->start(
    array(
        "id" => "export",
        "text" => "Export",
    )
);

$menu->item(
    array(
        "id" => "export_pdf",
        "text" => "PDF",
        "enabled" => "false"
    )
);

$menu->end(); // end export
$menu->end(); // end file

$menu->header();
echo $menu->result();
?>

Result

<?xml version="1.0" encoding="iso-8859-1"?>
<menu>
    <item id="file" text="File">
        <userdata name="some1">Value 1</userdata>
        <item id="new" text="New"/>
        <item id="ms1" type="separator"/>
        <item id="export" text="Export">
            <item id="export_pdf" text="PDF" enabled="false"/>
        </item>
    </item>
</menu>

Author

Lucas Tiago de Moraes

Support

Group DHTMLX Facebook